简体   繁体   English

Elasticsearch 术语查询大小以包括一些术语

[英]Elasticsearch terms query size to include some terms

Elasticsearch docs shows below example for size and includes Elasticsearch 文档显示了以下尺寸示例,包括

GET /_search
{
  "aggs": {
    "JapaneseCars": {
      "terms": {
        "field": "make",
        "size": 10
        "include": [ "mazda", "honda" ]
      }
    }
  }
}

But here "include" only includes "mazda" and "honda" in results, i want result to include those 2 as well other results based on doc_count since i am using size in query, is there any way to achieve this.但是这里“include”在结果中只包括“mazda”和“honda”,我希望结果包括这两个结果以及基于 doc_count 的其他结果,因为我在查询中使用了 size,有什么办法可以实现这一点。

terms aggregation always return buckets with highest number of documents. terms聚合总是返回文档数量最多的桶。

You cannot define an aggregation to always include buckets for some specified keys AND other top buckets.您不能将聚合定义为始终包含某些指定键的存储桶和其他顶级存储桶。

But you could define two separate aggregations and merge buckets in your application但是您可以在应用程序中定义两个单独的聚合和合并桶

GET /_search
{
  "aggs": {
    "JapaneseCars": {
      "terms": {
        "field": "make",
        "include": [ "mazda", "honda" ]
      }
    },
    "OtherCars": {
      "terms": {
        "field": "make",
        "exclude": [ "mazda", "honda" ]
      }
    },
  }
}

You can skip the include keyword right:可以直接跳过include关键字:

GET /_search
{
  "aggs": {
    "JapaneseCars": {
      "terms": {
        "field": "make",
        "size": 10
      }
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM