在 ElasticSearch 中获取包含文档的桶

Get buckets containing documents in ElasticSearch

我有这样的查询:

https://pastebin.com/9YK6WxEJ

这给了我:

https://pastebin.com/ranpCnzG

现在,存储桶很好,但我想获取按存储桶名称分组​​的文档数据,而不仅仅是它们在 doc_count 中的计数。有什么办法吗?

也许这对你有用?

"aggs": {
    "rating_ranges": {
      "range": {
        "field": "AggregateRating",
        "keyed": true,
        "ranges": [
          {
            "key": "bad",
            "to": 3
          },
          {
            "key": "average",
            "from": 3,
            "to": 4
          },
          {
            "key": "good",
            "from": 4
          }
        ]
      },
      "aggs": {
        "hits": {
          "top_hits": {
            "size": 100,
            "sort": [
              {
                "AggregateRating": {
                  "order": "desc"
                }
              }
            ]
          }
        }
      }
    }
  }