Wildcard Analysis in simple_query_string Query


I wonder how ES analyzes wildcard in simple_query_string queries. Specifically, what happens when query string includes a stop word and asterisk (*).

In my case,

My index has a custom analyzer with a bunch of filters including stop word filter and a char filter. And I'm running a simple_query_string query by setting analyze_wildcard option to true and query string to (<a stop word>*). How does analyzer work in this case?


  • I get no hits.
  • I get hits when analyze_wildcard is set to false. (i.e There are entries of which queried field value is starting with <a stop word> in query string.)

You can run your query with the explain parameter and you will see what the final query looked like, that may help getting down to your issue.

See https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-request-body.html#request-body-search-explain

In documentation, it says:

Enables explanation for each hit on how its score was computed.

It helped for analyze_wildcard = false case, that I get hits. But no good for my main question where analyze_wildcard option is set to true :frowning:

You can use the dedicated explain API for this.

Thanks for your help @spinscale :slight_smile:

I got what I want here. I just want to report that analysis of wildcard terms looks a little bit problematic, and analyze_wildcard is explained in an uncertain way in the documentation. Even, there is an open issue about it from 2016 :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.