0
votes

Is there a way to add a filter to a terms aggregation so I get just the ones starting with certain string?

I'm starting from here:

{
  "query": {
    "match_all": {}
  },
  "aggs": {
    "address": {
      "terms": {
        "field": "address"
      }
    }
  }
}
1

1 Answers

2
votes

Use the include or exclude parameters:

{
  "query": {
    "match_all": {}
  },
  "aggs": {
    "address": {
      "terms": {
        "field": "address",
        "include": "Main.*"     <-- add this
      }
    }
  }
}