Elasticsearch 聚合限制

发布于 2025-01-11 08:54:36 字数 630 浏览 0 评论 0原文

当我创建聚合查询时,它适用于什么范围:索引中的所有条目还是仅前 10000 个条目? 例如,以下是我得到的脚本指标聚合响应:

{
    "took": 76,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 10000,
            "relation": "gte"
        },
        "max_score": null,
        "hits": []
    },
    "aggregations": {
        "number_of_operations_in_progress": {
            "value": 2
        }
    }
}

hits->total->value is 10000 这让我认为聚合函数仅应用于前 10000 个条目,而不是索引中的整个数据集。

我的理解正确吗?如果是,有没有办法将聚合函数应用于所有条目?

When I create an aggregate query what scope it is applied to: all entries in an index or just first 10000?
For example, here is a response I got for a script metric aggregation:

{
    "took": 76,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 10000,
            "relation": "gte"
        },
        "max_score": null,
        "hits": []
    },
    "aggregations": {
        "number_of_operations_in_progress": {
            "value": 2
        }
    }
}

hits->total->value is 10000 what makes me think that the aggregate function is applied to first 10000 entries only, not the whole data set in the index.

Is my understanding correct? If yes, is there a way to apply an aggregate function to all entries?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黯淡〆 2025-01-18 08:54:36

聚合始终应用于查询选择的整个文档集。

hits.total.value 仅提示有多少文档与查询匹配,在本例中超过 10K 文档与查询匹配。

Aggregations are always applied to the whole document set that is selected by the query.

hits.total.value only gives a hint at how many documents match the query, in this case more than 10K documents match the query.

别再吹冷风 2025-01-18 08:54:36

您可以使用 track_total_hits 来控制如何跟踪点击总数

POST index1/_search
{
  "track_total_hits": true,
  "query": {
    "match_all": {}
  },
  "aggs": {
    "groupbyk1": {
      "terms": {
        "field": "k1"
      }
    }
  }
}

you can usr track_total_hits to control how the total number of hits should be tracked

POST index1/_search
{
  "track_total_hits": true,
  "query": {
    "match_all": {}
  },
  "aggs": {
    "groupbyk1": {
      "terms": {
        "field": "k1"
      }
    }
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文