[
https://issues.apache.org/jira/browse/LUCENE-6227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186972#comment-15186972
]
yuejianjun commented on LUCENE-6227:
------------------------------------
/**
* filter 查询结果(Filter 过滤查询)。 filter=id:1,2
*/
@SuppressWarnings("deprecation")
public TermsFilter getTermsFilter(String filter) {
try {
if (filter != null && filter.length() > 0) {
String[] arrFilter = filter.split(":");
if (arrFilter.length != 2) {
return null;
}
String key = arrFilter[0];
String[] values = arrFilter[1].split(",");
List<Term> listTerms = new ArrayList<Term>();
for (String value : values) {
listTerms.add(new Term(key, value));
}
if (listTerms.size() > 0) {
return new TermsFilter(listTerms);
}
}
} catch (Exception e) {
logger.error("SearchQuery getTermsFilter is error", e);
}
return null;
}
search id=1 or id=2
how to use BooleanClause.Occur.FILTER replace ?
> Add BooleanClause.Occur.FILTER
> ------------------------------
>
> Key: LUCENE-6227
> URL: https://issues.apache.org/jira/browse/LUCENE-6227
> Project: Lucene - Core
> Issue Type: Improvement
> Reporter: Adrien Grand
> Assignee: Adrien Grand
> Priority: Minor
> Fix For: 5.1, master
>
> Attachments: LUCENE-6227.patch, LUCENE-6227.patch, LUCENE-6227.patch,
> LUCENE-6227.patch, LUCENE-6227.patch
>
>
> Now that we have weight-level control of whether scoring is needed or not, we
> could add a new clause type to BooleanQuery. It would behave like MUST exept
> that it would not participate in scoring.
> Why do we need it given that we already have FilteredQuery? The idea is that
> by having a single query that performs conjunctions, we could potentially
> take better decisions. It's not ready to replace FilteredQuery yet as
> FilteredQuery has handling of random-access filters that BooleanQuery
> doesn't, but it's a first step towards that direction and eventually
> FilteredQuery would just rewrite to a BooleanQuery.
> I've been calling this new clause type FILTER so far, but feel free to
> propose a better name.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]