0

Need help transforming this query from using facet_filter to using aggs in ES 2.0 since facets are no longer supported in ES 2.0 and above.

{
  "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"
      }
    }
  ]
}

1 Answers1

1

Aggregations are almost the same you should be using smth like this

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

But its a bit different uproach if you are filtering, to read value you would need to get format_filter then inside of it you will find aggregation. Filtering inside of aggregation is the same

Vova Bilyachat
  • 18,765
  • 4
  • 55
  • 80