Eric
Eric

Reputation: 389

Elastic Search Using a wildcard within query_string exact search

Having an issue trying to get a wildcard into and elastic search exact phrase search using query_string.

Want to allow results to be returned that would be an exact phrase of all variations. i.e. "Coors Brewing", "Coors Brewery", "Coors Brews", etc.

POST _search
{
"query": {
  "query_string": {
    "default_operator": "AND", 
    "analyze_wildcard": true,
    "query": "\"coors brew*\""
  }
}
}

I am not married to this approach, but would like to search the majority of the document to find the matches vs 1 or 2 fields.

Upvotes: 4

Views: 3576

Answers (1)

ThomasC
ThomasC

Reputation: 8165

It seems to be a perfect use case for the match_phrase_prefix query (documentation) : did you give it a try?

If you need to make your query on multiple fields at the same time, take a look to the multi_match queries with phrase_prefix type (documentation).

Difference with your wilcard-based query_string query is the fact that the match queries aren't parsed and though don't support query_string syntax.

Upvotes: 1

Related Questions