Elastic query DSL: Wildcards in terms filter? Elastic query DSL: Wildcards in terms filter? elasticsearch elasticsearch

Elastic query DSL: Wildcards in terms filter?


The terms filter doesn't support wildcards, queries do, though. Try this query instead

{  "query": {    "bool": {      "must": {        "wildcard": {          "aircraft": "a380*"        }      }    }  }}

Or if you absolutely need to use filters, you can try the regexp filter, too:

{  "query": {    "filtered": {      "filter": {        "bool": {          "must": {            "regexp": {              "aircraft": "a380.*"            }          }        }      }    }  }}

UPDATE:

In latest ES versions, use the following query instead since filtered has been removed:

{  "query": {    "bool": {      "filter": {         "regexp": {           "aircraft": "a380.*"         }      }    }  }}