Elasticsearch query aggregation only terms with a specific pattern

I have done this query:

{
  "size": 0,
  "query": {
    "query_string": {
      "query": "*",
      "analyze_wildcard": true
    }
  },
  "_source": {
    "excludes": []
  },
  "aggs": {
    "2": {
      "terms": {
        "field": "tokens.keyword",
        "size": 50,
        "order": {
          "_count": "desc"
        }
      }
    }
  }
}

This return me the 50 most frequents keywords in my tokens (list of token). I tried to do a request to get the 50 most frequents keywords that start with the characters: "@" how can I do so?

See the include clause: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_filtering_values_with_regular_expressions

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.