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.

1
  • 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. Commented Oct 30, 2014 at 22:24

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.