elasticsearch—按另一个字段排序的聚合,通过复合ElasticSearch分页

igsr9ssn  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(0)|浏览(273)

我有以下聚合,通过复合聚合顺序分页

"aggs":{
  "aggregation1": {
    "composite": {
      "size":50, 
      "sources": [
        {
          "branches": {
             "terms": {
              "field": "someField1",
              "order": "desc"
            }
          }
        }
      ]
    },
     "aggs": {
        "aggregation2": {
          "terms": {
            "field": "someField2",
            "size": 10
          }
        }
      }
  }
}

在此之前,我使用分页槽分区:

"aggs": {
    "aggregation1": {
      "terms": {
        "field": "someField1",
        "size": 50,
        "order": {
          "last_created": "desc"
        },
        "include": {
          "partition":0,
          "num_partitions": 3
        }
      },
      "aggs": {
        "aggregation2": {
          "terms": {
            "field": "someField2",
            "size": 10
          }
        },
        "last_created": {
          "max": {
            "field": "created"
          }
        }
      }
    }
  }

我的问题是,当我在查询2中使用分区时,如何按“created”字段对第一个查询排序?
p、 我试图添加到“来源”,因为他们在链接

{
        "last_created":
          {
            "terms":{
              "field":"created",
              "order": "desc"
            }
          }
        }

但我得到了错误的结果和重复的领域1

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题