繁体   English   中英

如何使用From / Size控制Elasticsearch聚合结果?

[英]How to control the elasticsearch aggregation results with From / Size?

我一直试图在弹性搜索词聚合中添加分页。 在查询中,我们可以添加分页,例如

 {
    "from": 0, // to add the start to control the pagination
    "size": 10,
    "query": { } 
 }

这很清楚,但是当我想在聚合中添加分页时,我读了很多,但是找不到任何东西,我的代码看起来像这样,

{
  "from": 0,
  "size": 0,
  "aggs": {
    "group_by_name": {
      "terms": {
        "field": "name",
        "size": 20
      },
      "aggs": {
        "top_tag_hits": {
          "top_hits": {
            "size": 1
          }
        }
      }
    }
  }
}

有什么方法可以创建带有函数的分页或任何其他建议?

好像您可能想要分区。 从文档:

有时在单个请求/响应对中要处理的唯一术语过多,因此将分析分解为多个请求可能很有用。 这可以通过在查询时将字段的值分为多个分区并在每个请求中仅处理一个分区来实现。

基本上,您添加"include": { "partition": n, "num_partitions": x }, ,,其中n是页面, x是页面数。

不幸的是,此功能是最近才添加的。 如果可以在产生此功能的GitHub Issue上相信这些标签,则至少需要使用Elasticsearch 5.2或更高版本。

暂无
暂无

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

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