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
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!