聚合的弹性搜索方面

elastic search facet to aggregation

需要帮助将此查询从使用 facet_filter 转换为使用 ES 2.0 中的聚合,因为 ES 2.0 及更高版本不再支持分面。

{
  "facets": {
    "format": {
      "terms": {
        "field": "documentary_tag_id",
        "size": 10,
        "exclude": ["2"]
      },
      "facet_filter": {
        "term": {
          "documentary_tag_id": ["2"]
        }
      }
    }
  },
  "sort": [
    "_score",
    {
      "documentary_tag_name": {
        "order": "desc"
      }
    }
  ]
}

聚合几乎相同,您应该像这样使用 smth

GET _search
{
  "aggs": {
    "format_filter": {
      "filter": {
        "terms": {
          "documentary_tag_id": [
            "2"
          ]
        }
      },
      "aggs": {
        "format": {
          "terms": {
            "field": "documentary_tag_id",
          "exclude" : "2"
          }
        }
      }
    }
  }
}

但是如果你 are filtering, to read value you would need to get format_filter then inside of it you will find aggregation. Filtering 聚合内部是一样的