AWS打开搜索关键字聚合结果问题与匹配的通配符搜索

发布于 2025-02-06 05:50:23 字数 5997 浏览 1 评论 0原文

         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"
        ]
      }
    
    ]

当我尝试汇总Company_data.name的结果时,我将始终获得company_data数组名称的最高索引,并带有结果计数。这是我试图在AWS Workbench中应用的查询,

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

这是我始终带来的第一个索引元素的结果

{
  "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
        }
       
      ]
    }
  }
}

,但是我需要匹配的索引元素“ US专利和商标办公室”,因为它可以匹配搜索关键字“ US”。请让我知道我是否需要更改请求参数以在汇总中获得精确的索引。

谢谢!!

         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!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文