[
https://issues.apache.org/jira/browse/LUCENE-6570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14592660#comment-14592660
]
Hoss Man commented on LUCENE-6570:
----------------------------------
I'm confused about the status of this issue.
it's currently marked "Resolved" in 6.0, and trunk has the new API with all of
the formerly public constructors for BooleanQuery completely deleted -- but i
don't see any commits/patches/mentions to backporting the builder & marking
these constructors deprecated in the 5x branch. (let alone any mention in
MIGRATE.txt)
----
I'm also not sure how i feel about the defensive cloning of (sub) queries here.
It's a significant enough difference from how constructing BooleanQueries
worked in the past that at an absolute minimum the javadocs for the builder
should be crystal clear that a clone is happening under the covers -- but it
also means that users who have existing code like this...
{code}
public final static REUSED_FILTER = buildReallyMassiveQueryForReuse();
...
loop {
BooleanQuery bq = new BooleanQuery();
bq.add(REUSED_FILTER, MUST);
bq.add(buildQueryFromInput, MUST);
...
doSomeSearch(bq);
}
{code}
...are now going to be seeing REUSED_FILTER get cloned for every query. Again,
at a minimum, this needs to be heavily spelled out in the MIGRATE and other
docs, but personally i think it's going to far and we shouldn't be making these
defensive clones.
> Make BooleanQuery immutable
> ---------------------------
>
> Key: LUCENE-6570
> URL: https://issues.apache.org/jira/browse/LUCENE-6570
> Project: Lucene - Core
> Issue Type: Task
> Reporter: Adrien Grand
> Assignee: Adrien Grand
> Priority: Minor
> Fix For: 6.0
>
> Attachments: LUCENE-6570.patch
>
>
> In the same spirit as LUCENE-6531 for the PhraseQuery, we should make
> BooleanQuery immutable.
> The plan is the following:
> - create BooleanQuery.Builder with the same setters as BooleanQuery today
> (except setBoost) and a build() method that returns a BooleanQuery
> - remove setters from BooleanQuery (except setBoost)
> I would also like to add some static utility methods for common use-cases of
> this query, for instance:
> - static BooleanQuery disjunction(Query... queries) to create a disjunction
> - static BooleanQuery conjunction(Query... queries) to create a conjunction
> - static BooleanQuery filtered(Query query, Query... filters) to create a
> filtered query
> Hopefully this will help keep tests not too verbose, and the latter will also
> help with the FilteredQuery derecation/removal.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]