本文整理匯總了Java中org.apache.lucene.search.BooleanClause.isProhibited方法的典型用法代碼示例。如果您正苦於以下問題:Java BooleanClause.isProhibited方法的具體用法?Java BooleanClause.isProhibited怎麽用?Java BooleanClause.isProhibited使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.lucene.search.BooleanClause
的用法示例。
在下文中一共展示了BooleanClause.isProhibited方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addExtraQuery
import org.apache.lucene.search.BooleanClause; //導入方法依賴的package包/類
/**
* @dytech.jira see Jira Review TLE-784 :
* http://apps.dytech.com.au/jira/browse/TLE-784
*/
protected Query addExtraQuery(@Nullable Query query, Search searchreq, IndexReader reader)
{
FreeTextQuery fullftQuery = searchreq.getFreeTextQuery();
if( fullftQuery == null )
{
return query;
}
BooleanClause clause = convertToBooleanClause(fullftQuery, reader);
if( !clause.isProhibited() && !clause.isRequired() )
{
clause.setOccur(Occur.MUST);
}
BooleanQuery andThem = new BooleanQuery();
andThem.add(clause);
if( query != null )
{
andThem.add(query, Occur.MUST);
}
return andThem;
}
示例2: isNegativeQuery
import org.apache.lucene.search.BooleanClause; //導入方法依賴的package包/類
private static boolean isNegativeQuery(Query q) {
if (!(q instanceof BooleanQuery)) {
return false;
}
List<BooleanClause> clauses = ((BooleanQuery) q).clauses();
if (clauses.isEmpty()) {
return false;
}
for (BooleanClause clause : clauses) {
if (!clause.isProhibited()) return false;
}
return true;
}
示例3: doAssertLuceneQuery
import org.apache.lucene.search.BooleanClause; //導入方法依賴的package包/類
@Override
protected void doAssertLuceneQuery(BoolQueryBuilder queryBuilder, Query query, SearchContext searchContext) throws IOException {
if (!queryBuilder.hasClauses()) {
assertThat(query, instanceOf(MatchAllDocsQuery.class));
} else {
QueryShardContext context = searchContext.getQueryShardContext();
List<BooleanClause> clauses = new ArrayList<>();
clauses.addAll(getBooleanClauses(queryBuilder.must(), BooleanClause.Occur.MUST, context));
clauses.addAll(getBooleanClauses(queryBuilder.mustNot(), BooleanClause.Occur.MUST_NOT, context));
clauses.addAll(getBooleanClauses(queryBuilder.should(), BooleanClause.Occur.SHOULD, context));
clauses.addAll(getBooleanClauses(queryBuilder.filter(), BooleanClause.Occur.FILTER, context));
if (clauses.isEmpty()) {
assertThat(query, instanceOf(MatchAllDocsQuery.class));
} else {
assertThat(query, instanceOf(BooleanQuery.class));
BooleanQuery booleanQuery = (BooleanQuery) query;
assertThat(booleanQuery.isCoordDisabled(), equalTo(queryBuilder.disableCoord()));
if (queryBuilder.adjustPureNegative()) {
boolean isNegative = true;
for (BooleanClause clause : clauses) {
if (clause.isProhibited() == false) {
isNegative = false;
break;
}
}
if (isNegative) {
clauses.add(new BooleanClause(new MatchAllDocsQuery(), BooleanClause.Occur.MUST));
}
}
assertThat(booleanQuery.clauses().size(), equalTo(clauses.size()));
Iterator<BooleanClause> clauseIterator = clauses.iterator();
for (BooleanClause booleanClause : booleanQuery.clauses()) {
assertThat(booleanClause, instanceOf(clauseIterator.next().getClass()));
}
}
}
}