1
         I have setup indexed data on open search , here is some sample data 
 [{
        "_index" : "news-2022-05-25",
        "_type" : "_doc",
        "_id" : "49629288243749591350894282888456290133282338307278110722.0",
        "_score" : null,
        "_source" : {
          "company_data" : [
            {
              "method" : "extractor",
              "UDUNS" : "079942718",
              "UACORN" : "1571433801",
              "company_id_numbers" : "DUNS:060902413;NECOID:2022175272;ACORN:2011175272;ORBISID:151166135;UORBISID:319522152;UDUNS:079942718;UACORN:1571433801",
              "UORBISID" : "319522152",
              "relevance" : "SIGNIFICANT",
              "field11" : "XXXX",
              "field12" : "REFERENCE",
              "field1" : "",
              "field10" : "",
              "DUNS" : "060902413",
              "name" : "Google LLC",
              "field9" : "",
              "ACORN" : "2011175272",
              "ORBISID" : "151166135",
              "field8" : "",
              "NECOID" : "2022175272",
              "field3" : "",
              "field2" : ""
            },
            {
              "method" : "extractor",
              "company_id_numbers" : "DUNS:079942718;NECOID:1582433801;ACORN:1571433801;ORBISID:319522152",
              "ISIN" : "US02079K1079",
              "relevance" : "SIGNIFICANT",
              "field11" : "XNAS",
              "CUSIP" : "02079K107",
              "field12" : "REFERENCE",
              "field1" : "NASDAQ-NMS",
              "field10" : "",
              "DUNS" : "079942718",
              "name" : "Alphabet Inc.",
              "field9" : "PARENT",
              "ACORN" : "1571433801",
              "ORBISID" : "319522152",
              "field8" : "",
              "NECOID" : "1582433801",
              "field3" : "CUSIP:02079K107;ISIN:US02079K1079",
              "field2" : "GOOG"
            },
            {
              "method" : "extractor",
              "UDUNS" : "161906193",
              "UACORN" : "2653674111",
              "company_id_numbers" : "DUNS:070921085;NECOID:201872415;ACORN:0190872415;ORBISID:209885097;UORBISID:032976297;UDUNS:161906193;UACORN:2653674111",
              "UORBISID" : "032976297",
              "relevance" : "SIGNIFICANT",
              "field11" : "XXXX",
              "field12" : "REFERENCE",
              "field1" : "",
              "field10" : "",
              "DUNS" : "070921085",
              "name" : "US Patent and Trademark Office",
              "field9" : "",
              "ACORN" : "0190872415",
              "ORBISID" : "209885097",
              "field8" : "",
              "NECOID" : "201872415",
              "field3" : "",
              "field2" : ""
            }
          ]
        },
        "sort" : [
          "US Patent and Trademark Office"
        ]
      }


      {
        "_index" : "news-2022-05-25",
        "_type" : "_doc",
        "_id" : "49629288243749591350894282888930189054571274043274559490.0",
        "_score" : null,
        "_source" : {
          "company_data" : [
            {
              "method" : "extractor",
              "UDUNS" : "962519000",
              "company_id_numbers" : "DUNS:124998217;NECOID:468925;ACORN:1082656332;ORBISID:075163318;UDUNS:962519000",
              "relevance" : "SIGNIFICANT",
              "field11" : "XXXX",
              "field12" : "REFERENCE",
              "field1" : "",
              "field10" : "",
              "DUNS" : "124998217",
              "name" : "Lumileds LLC",
              "field9" : "",
              "ACORN" : "1082656332",
              "ORBISID" : "075163318",
              "field8" : "",
              "NECOID" : "468925",
              "field3" : "",
              "field2" : ""
            },
            {
              "method" : "extractor",
              "UDUNS" : "161906193",
              "UACORN" : "2653674111",
              "company_id_numbers" : "DUNS:070921085;NECOID:201872415;ACORN:0190872415;ORBISID:209885097;UORBISID:032976297;UDUNS:161906193;UACORN:2653674111",
              "UORBISID" : "032976297",
              "relevance" : "SIGNIFICANT",
              "field11" : "XXXX",
              "field12" : "REFERENCE",
              "field1" : "",
              "field10" : "",
              "DUNS" : "070921085",
              "name" : "US Patent and Trademark Office",
              "field9" : "",
              "ACORN" : "0190872415",
              "ORBISID" : "209885097",
              "field8" : "",
              "NECOID" : "201872415",
              "field3" : "",
              "field2" : ""
            }
          ]
        },
        "sort" : [
          "US Patent and Trademark Office"
        ]
      }
    
    ]

when i try to aggregate result for company_data.name i am getting always the top index of company_data array name with result count. Here is the Query I am trying to apply in aws workbench

{
  "size": 500,
  "query": {
    "bool": {
        "must": [
          {
              "wildcard": {
              "company_data.name.keyword": "US*"
            }
          }
        ]
      }
  },
  "sort": [
    {
      "company_data.name.keyword": {
        "order": "desc"
      }
    }
  ], 
  "_source": [
    "company_data"
  ]
}

Here is the result I am getting

{
  "took" : 5,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2496,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "company_data.name" : {
      "doc_count_error_upper_bound" : 10,
      "sum_other_doc_count" : 3408,
      "buckets" : [
       
        {
          "key" : "Google LLC",
          "doc_count" : 1
        },
        {
          "key" : "Lumileds LLC",
          "doc_count" : 1
        }
       
      ]
    }
  }
}

Always brings the first index element , but I need the matched index element "US Patent and Trademark Office" as it matches to search keyword "US". Please let me know if any thing i need to change in request params to get exact index in aggregation.

Thanks!!

0 Answers0