elasticsearch 在不同顺序的弹性搜索中具有聚合性能的查询?,elasticsearch,lucene,aggregation,elasticsearch,Lucene,Aggregation" /> elasticsearch 在不同顺序的弹性搜索中具有聚合性能的查询?,elasticsearch,lucene,aggregation,elasticsearch,Lucene,Aggregation" />

elasticsearch 在不同顺序的弹性搜索中具有聚合性能的查询?

elasticsearch 在不同顺序的弹性搜索中具有聚合性能的查询?,elasticsearch,lucene,aggregation,elasticsearch,Lucene,Aggregation,我有一个要求,即我有一组特定于不同配置的文档,我需要返回基于configVersion的最新配置。但我还有其他需要匹配的查询参数。在这种情况下,以下哪一项的性能更快 1) 首先使用聚合列出基于configVersion的最新配置,然后应用查询进行获取。 2) 首先应用查询以获取匹配的记录,然后应用聚合 备选案文1: { "size": 10000, "aggs": { "finalFilter": { "terms": { "field": "c

我有一个要求,即我有一组特定于不同配置的文档,我需要返回基于configVersion的最新配置。但我还有其他需要匹配的查询参数。在这种情况下,以下哪一项的性能更快

1) 首先使用聚合列出基于configVersion的最新配置,然后应用查询进行获取。 2) 首先应用查询以获取匹配的记录,然后应用聚合

备选案文1:

{
  "size": 10000,

    "aggs": {
    "finalFilter": {
      "terms": {
        "field": "configName",
        "size": 10000
      },
      "aggs": {
        "latest": {
          "top_hits": {
            "size": 1,
            "sort": {
              "configVersion": "desc"
            }
          }
        }
      }
    }
  },
  "query": {
    "bool": {
      "filter": {
        "bool": {
          "must": [
            {
                "term": {
                   "configName": "configuration1"
                }

            },
            {
              "term": {
                "Application": "Google"
              }
            },

            {
              "term": {
                "platform": "windows"
              }
            },
            {
              "term": {
                "ApplicationVersion": "1.1"
              }
            },
            {
              "term": {
                "country": "uk"
              }
            }
          ]
        }
      }
    }
  }
}
备选案文2:

{ “大小”:10000, “查询”:{ “布尔”:{ “过滤器”:{ “布尔”:{ “必须”:[ { “期限”:{ “配置名称”:“配置1” } }, { “期限”:{ “应用程序”:“谷歌” } }, { “期限”:{ “平台”:“windows” } }, { “期限”:{ “应用程序版本”:“1.1” } }, { “期限”:{ “国家”:“英国” } } ] } } } }, “aggs”:{ “最终过滤器”:{ “条款”:{ “字段”:“配置名称”, “尺寸”:10000 }, “aggs”:{ “最新”:{ “热门歌曲”:{ “大小”:1, “排序”:{ “配置版本”:“描述” } } } } } } }
谢谢
Sushma

您的查询看起来相同,但在第二个示例中,AGG出现在查询之后-或者我遗漏了什么?是的,它们是相同的,实际上查询+聚合在执行中花费了更多的时间,因此我正在尝试为其找到优化的查询。因此,我怀疑聚合+查询或查询+聚合将提供更好的结果。这不会有任何区别-Elasticsearch将首先运行查询/筛选,然后进行聚合。将AGG放在查询之前或之后并不重要。

{ "size": 10000, "query": { "bool": { "filter": { "bool": { "must": [ { "term": { "configName": "configuration1" } }, { "term": { "Application": "Google" } }, { "term": { "platform": "windows" } }, { "term": { "ApplicationVersion": "1.1" } }, { "term": { "country": "uk" } } ] } } } }, "aggs": { "finalFilter": { "terms": { "field": "configName", "size": 10000 }, "aggs": { "latest": { "top_hits": { "size": 1, "sort": { "configVersion": "desc" } } } } } } }