HI Folks,

I am tasked with migrating a Solr app from Solr 4 to Solr 6. This solr app
is in essence a bunch of solr components/handlers. One part that challenges
me is BooleanQuery immutability in Solr 6.

Here is the challenge: In our old code base, we had classes that
implemented custom interfaces and extended BooleanQuery. These custom
interfaces were essentially markers that told our various components where
the user came from. Based on the user's origin, different pieces of logic
would apply.

Now, in Solr 6, our custom boolean query  can no longer extend BooleanQuery
since BooleanQuery only has a private constructor. I am looking for a clean
solution to this problem.

Here are some ideas I had:

1) Remove the logic that depends on the custom boolean query => Big risk to
our search logic
2) Simply remove BooleanQuery as super class of custom boolean query =>
Major risk. Wherever we do “if(query instanceof BooleanQuery) “, we would
not catch our custom queries.
3) Remove BooleanQuery as parent to the custom query (e.g. make it extend
Query) AND Refactor to move all “if(query instanceof BooleanQuery) “ into a
dedicated method: isCustomBooleanQuery. This would return “query instanceof
BooleanQuery || “query instanceof CustomQuery“. We then need to change ALL
20 occurrences of this test and ensure we handle both cases appropriately.
==> Very invasive.
4) Add a method createCustomQuery() that would return a boolean query
wherein a special clause is added that allows us to identify our custom
queries.  This special clause should not impact search results. => Pretty
ugly.


Other potential clean, low risk, and less invasive solution?


Max.

Reply via email to