You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Greg Huber (JIRA)" <ji...@apache.org> on 2015/08/26 10:36:47 UTC
[jira] [Comment Edited] (LUCENE-6570) Make BooleanQuery immutable
[ https://issues.apache.org/jira/browse/LUCENE-6570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14712704#comment-14712704 ]
Greg Huber edited comment on LUCENE-6570 at 8/26/15 8:36 AM:
-------------------------------------------------------------
Hello,
I am extending AnalyzingInfixSuggester for use with my suggester where I change the query to be a AND rather than an OR in the finishQuery(..) method.
ie
/**
* Subclass can override this to tweak the Query before searching.
*/
protected Query finishQuery(Builder in, boolean allTermsRequired) {
// Update contexts to be ANDs (MUST) rather than ORs (SHOULD)
for (BooleanClause booleanClause : in.build().clauses()) {
// Change the contexts to be MUST (will be the only BooleanQuery and others will be TermQuery)
if (booleanClause.getQuery() instanceof BooleanQuery) {
BooleanQuery bq = (BooleanQuery) booleanClause.getQuery();
for (BooleanClause bc : bq) {
bc.setOccur(BooleanClause.Occur.MUST);
}
// We are done
break;
}
}
return in.build();
}
It says that BooleanClause.setOccur(..) is depreciated and will be immutable in 6.0, how would I then be able to do this?
Cheers Greg
was (Author: gregh99):
Hello,
I am extending AnalyzingInfixSuggester for use with my suggester where I change the query to be a AND rather than an OR in the finishQuery(..) method.
ie
/**
* Subclass can override this to tweak the Query before searching.
*/
protected Query finishQuery(Builder in, boolean allTermsRequired) {
// Update contexts to be ANDs (MUST) rather than ORs (SHOULD)
for (BooleanClause booleanClause : in.build().clauses()) {
// Change the contexts to be MUST (will be the only BooleanQuery and others will be TermQuery)
if (booleanClause.getQuery() instanceof BooleanQuery) {
BooleanQuery bq = (BooleanQuery) booleanClause.getQuery();
for (BooleanClause bc : bq) {
bc.setOccur(BooleanClause.Occur.MUST);
}
// We are done
break;
}
}
return in.build();
}
It says that BooleanClause.setOccur(..) is depreciated and will be immutable in 6.0, how would I then be able to do this?
> 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: 5.3, 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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org