use of com.zimbra.cs.index.LuceneQueryOperation in project zm-mailbox by Zimbra.
the class DomainQuery method compile.
@Override
public QueryOperation compile(Mailbox mbox, boolean bool) {
LuceneQueryOperation op = new LuceneQueryOperation();
op.addClause(toQueryString(field, term), new TermQuery(new Term(field, term)), evalBool(bool));
return op;
}
use of com.zimbra.cs.index.LuceneQueryOperation in project zm-mailbox by Zimbra.
the class TextQuery method compile.
@Override
public QueryOperation compile(Mailbox mbox, boolean bool) throws ServiceException {
if (quick || text.endsWith("*")) {
// wildcard, must look at original text here b/c analyzer strips *'s
// only the last token is allowed to have a wildcard in it
String last = tokens.isEmpty() ? text : tokens.remove(tokens.size() - 1);
LuceneQueryOperation.LazyMultiPhraseQuery query = new LuceneQueryOperation.LazyMultiPhraseQuery();
for (String token : tokens) {
query.add(new Term(field, token));
}
// expand later
query.expand(new Term(field, CharMatcher.is('*').trimTrailingFrom(last)));
LuceneQueryOperation op = new LuceneQueryOperation();
op.addClause(toQueryString(field, text), query, evalBool(bool));
return op;
} else if (tokens.isEmpty()) {
// a stop word like "a" or "an" or "the".
return new NoTermQueryOperation();
} else if (tokens.size() == 1) {
LuceneQueryOperation op = new LuceneQueryOperation();
op.addClause(toQueryString(field, text), new TermQuery(new Term(field, tokens.get(0))), evalBool(bool));
return op;
} else {
assert tokens.size() > 1 : tokens.size();
PhraseQuery query = new PhraseQuery();
for (String token : tokens) {
query.add(new Term(field, token));
}
LuceneQueryOperation op = new LuceneQueryOperation();
op.addClause(toQueryString(field, text), query, evalBool(bool));
return op;
}
}
use of com.zimbra.cs.index.LuceneQueryOperation in project zm-mailbox by Zimbra.
the class LuceneQuery method compile.
@Override
public QueryOperation compile(Mailbox mbox, boolean bool) {
LuceneQueryOperation op = new LuceneQueryOperation();
op.addClause(queryField + term, new TermQuery(new Term(luceneField, term)), evalBool(bool));
return op;
}
Aggregations