Multiple wildcards in one query in elasticsearch

user2742004 picture user2742004 · May 15, 2014 · Viewed 11.7k times · Source
curl localhost:9200/tweet/posts/_search -d '{
  "query": {
    "and": [
      {
        "wildcard": {
          "_all": "*pet*"
        }
      },
      {
        "wildcard": {
          "_all": "*rom*"
        }
      }
    ]
  }
}'

This gives me a parse exception. I want to run a MySQL like(%test%) type query with an AND condition. Is there any other good way to do in elasticsearch.

Answer

Alcanzar picture Alcanzar · May 15, 2014

Maybe something like this?

{
  "query": {
    "bool": {
      "must": [
        {
          "wildcard": {
            "_all": {
              "value": "*pet*"
            }
          }
        },
        {
          "wildcard": {
            "_all": {
              "value": "*rom*"
            }
          }
        }
      ]
    }
  }
}