4

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.

Eric
  • 369
  • 4
  • 5
  • Keep in mind that your query will match `"Coors Something_I_Didn't_Really_Wanted_To_Be_Matched Brewery"`, because of query analisys. And if I'm not mistaken you should use some fancy analyzer to deal with " chars. – Victor Suzdalev Oct 30 '14 at 22:24

1 Answers1

1

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.

ThomasC
  • 7,915
  • 2
  • 26
  • 26