lucene
lucene copied to clipboard
Make some BooleanQuery methods public and a new `#add(Collection)` method for BQ builder
Description
Changes in this PR :
- Makes
getClauses(Occur occurmethod public to get the collection of one type of clauses. Without public I had to callgetClausesand then iterate to store this info whereasBoolenQueryis already storing this info in clauseSets which seems like a good candidate to be exposed for reuse this method. This would also simplify not having checks like eg: 1, 2, 3, 4 etc along with theadd(Collection)method(point 3 below). - Similarly makes
#isPureDisjunctionandisTwoClausePureDisjunctionWithTermspublic which looks could be something useful and right thing to be exposed by theBooleanQueryclass. - Adds an
add(Collection<BooleanClause> collection)method toBooleanQuery.Builder. While doing some query manipulation I had to insert a set of clause but one by one. I'd be useful if there was aadd(Collection<BooleanClause> collection)to add the to the maintained list of clauses and simplify it for cases where users are manipulating the BQ. I see some places in code that could be refactored to avoid looping to insert the list of clauses as mentioned in point 1.
I'd love to hear thoughts and suggestions. I don't know if there are any rationale of not having these methods public earlier(or a previous attempt) but would love to know.