Exclude specific terms from term aggregation's buckets list

If anyone will have the same problem, the easiest solution is to add Exclude parameter:

GET newindex/_search
    {
      "query": {
        "query_string": {
          "default_field": "word", 
          "query" : "*table*"
        }
      },
      "aggs" : {
          "tables" : {
              "terms" : { 
                "field" : "word.s",
                "exclude": ".*table.*"
                "size" : 100
              }
          }
      },
      "size" : 0
    }
1 Like