use of org.apache.lucene.search.BooleanQuery in project neo4j by neo4j.
the class FullTxData method injectOrphans.
private Query injectOrphans(Query query) {
if (query instanceof BooleanQuery) {
BooleanQuery source = (BooleanQuery) query;
BooleanQuery.Builder builder = new BooleanQuery.Builder();
for (BooleanClause clause : source.clauses()) {
builder.add(injectOrphans(clause.getQuery()), clause.getOccur());
}
return builder.build();
}
String orphanField = extractTermField(query);
if (orphanField == null) {
return query;
}
return new BooleanQuery.Builder().add(query, Occur.SHOULD).add(new TermQuery(new Term(ORPHANS_KEY, orphanField)), Occur.SHOULD).build();
}
use of org.apache.lucene.search.BooleanQuery in project querydsl by querydsl.
the class LuceneSerializer method toTwoHandSidedQuery.
private Query toTwoHandSidedQuery(Operation<?> operation, Occur occur, QueryMetadata metadata) {
Query lhs = toQuery(operation.getArg(0), metadata);
Query rhs = toQuery(operation.getArg(1), metadata);
BooleanQuery bq = new BooleanQuery();
bq.add(createBooleanClause(lhs, occur));
bq.add(createBooleanClause(rhs, occur));
return bq;
}
use of org.apache.lucene.search.BooleanQuery in project querydsl by querydsl.
the class LuceneSerializer method notIn.
protected Query notIn(Operation<?> operation, QueryMetadata metadata, boolean ignoreCase) {
BooleanQuery bq = new BooleanQuery();
bq.add(new BooleanClause(in(operation, metadata, false), Occur.MUST_NOT));
bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST));
return bq;
}
use of org.apache.lucene.search.BooleanQuery in project querydsl by querydsl.
the class LuceneSerializer method ne.
protected Query ne(Operation<?> operation, QueryMetadata metadata, boolean ignoreCase) {
BooleanQuery bq = new BooleanQuery();
bq.add(new BooleanClause(eq(operation, metadata, ignoreCase), Occur.MUST_NOT));
bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST));
return bq;
}
use of org.apache.lucene.search.BooleanQuery in project querydsl by querydsl.
the class LuceneSerializer method endsWith.
protected Query endsWith(Operation<?> operation, QueryMetadata metadata, boolean ignoreCase) {
verifyArguments(operation);
Path<?> path = getPath(operation.getArg(0));
String field = toField(path);
String[] terms = convertEscaped(path, operation.getArg(1), metadata);
if (terms.length > 1) {
BooleanQuery bq = new BooleanQuery();
for (int i = 0; i < terms.length; ++i) {
String s = i == terms.length - 1 ? "*" + terms[i] : "*" + terms[i] + "*";
bq.add(new WildcardQuery(new Term(field, s)), Occur.MUST);
}
return bq;
}
return new WildcardQuery(new Term(field, "*" + terms[0]));
}
Aggregations