Wildcard queries and how Solr handles them

One of our readers reported a very interesting problem, which can be summarized to the following question – “Why doesn’t ReversedWildcardFilterFactory doesn’t work with Polish letters ?”. This entry will attempt to answer this question.

Type and field definition

Our reader has the following type of data defined in the schema.xml file:

One of the fields in the schema.xml file looks like this:


For the purpose of this post I used the following data:

Problem definition

The problem has been defined as follows: “I have the Polish characters in the field named word. When I make a wildcard request with the Polish character, such as “word:*ą*” Solr doesn’t find any documents“.

What should we remember when using ReversedWildcardFilterFactory

When using ReversedWildcardFilterFactory be sure to define this filter only for the index analyzer, and not to define it for query analyzer. Thus, a revised c_string definition should look like this:

Is it working now ?

When we send the follwing query to Solr:

It still does not return any results. Why ?

Solr and wildcard handling

The answer to the question posted above is simple enough – Solr does not analyze queries in which there are wildcards. Yes, this means that the filter ASCIIFoldingFilterFactory, during indexing, turns Polish characters onto their counterparts from the ASCII table characters, but when making queries this is not happening, despite the fact that the filters are defined correctly. And that is why we do not get any search results. However, in this was the case, we should get the query results after sending the following query:

And this is exactly the case, the above returns the search results we expected.

Possible solutions

If someone asked me what would I suggested to solve the problem, I would reply that at this time I would remove the Polish characters from the queries which have wildcards. Since version 1.5, Solr, ReversedWildcardFilterFactory will correctly handle characters outside the basic ASCII table, so there will be no need to use ASCIIFoldingFilterFactory, and hence, the problem will not exist.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.