【问题标题】:Elasticsearch: Sort top_hits aggregation _score and then doc countElasticsearch:排序 top_hits 聚合 _score 然后文档计数
【发布时间】:2018-09-30 17:29:09
【问题描述】:

我希望根据 _score 和文档数对聚合进行排序(如果多个文档的 _score 相同)。我现在拥有的是能够按_score排序

  "aggs": {
    "name": {
      "terms": {
        "field": "name",
        "order": {"by_score": "desc"}
      },
      "aggs": {
        "top_hits": {
          "top_hits": {
            "size": 1,
            "_source": ["name"]
          }
        },
        "by_score": {
          "max": {"script": { "source": "_score" }
          }
        }
      }
    }
  }

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    我想我在这里找到了答案Elasticsearch two level sort in aggregation list

    订单需要在数组中:

            "order": [
              {"by_score": "desc"},
              {"_count": "desc"}
            ]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-24
      • 2019-04-02
      • 1970-01-01
      • 2022-01-26
      • 1970-01-01
      • 1970-01-01
      • 2015-08-25
      • 2016-06-26
      相关资源
      最近更新 更多