Elasticsearch query aggregation only terms with a specific pattern


(Melvyn Peignon) #1

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?


(Mark Harwood) #2

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


(system) #3

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