FuzzyQuery issue with Solr RealTimeGet

Its almost more than 3 years without a post, many things happened in these 3 years which i had never seen in life or imagined that something like this can happen. But slowly and steadily Pandemic is receding and Good days are back! So i thought i would resume with some “Hard to Solve” problems and their solution, often not found on the internet.

When using RealTimeGet(/get) you can always use the FilterQuery(fq) param to filter the result documents. But when you use a FuzzyQuery you get this below mentioned Exception and the request fails:

ERROR o.a.solr.handler.RequestHandlerBase – java.lang.UnsupportedOperationException: Query Blended() does not implement createWeight
        at org.apache.lucene.search.Query.createWeight(Query.java:66)

If you have seen something like this here is a quick fix:

This basically happens due to the following statment in process() method in the org.apache.solr.handler.component.RealTimeGetComponent.java where we are using Query objects rewrite method, and FuzzyQuery does not implement createWeight method and hence the above exception is thrown

Query q = raw.rewrite(searcherInfo.getSearcher().getIndexReader());

So to fix this issue we need to write a Custom Solr SearchComponent and use IndexSearcher ‘s rewrite method as shown below:

Query q = searcherInfo.getSearcher().rewrite(raw);

That should do it!


About Dominic

J for JAVA more about me : http://about.me/dominicdsouza
This entry was posted in Thechy Stuff. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s