lucene icon indicating copy to clipboard operation
lucene copied to clipboard

Make some BooleanQuery methods public and a new `#add(Collection)` method for BQ builder

Open shubhamvishu opened this issue 1 year ago • 0 comments

Description

Changes in this PR :

  1. Makes getClauses(Occur occur method public to get the collection of one type of clauses. Without public I had to call getClauses and then iterate to store this info whereas BoolenQuery is 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 the add(Collection) method(point 3 below).
  2. Similarly makes #isPureDisjunction and isTwoClausePureDisjunctionWithTerms public which looks could be something useful and right thing to be exposed by the BooleanQuery class.
  3. Adds an add(Collection<BooleanClause> collection) method to BooleanQuery.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 a add(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.

shubhamvishu avatar Oct 23 '24 18:10 shubhamvishu