use of org.apache.lucene.queryparser.flexible.standard.nodes.PrefixWildcardQueryNode in project lucene-solr by apache.
the class WildcardQueryNodeProcessor method postProcessNode.
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
// we do the same here, also ignore empty terms
if (node instanceof FieldQueryNode || node instanceof FuzzyQueryNode) {
FieldQueryNode fqn = (FieldQueryNode) node;
CharSequence text = fqn.getText();
// QuotedFieldQueryNode to reproduce the old parser behavior
if (fqn.getParent() instanceof TermRangeQueryNode || fqn instanceof QuotedFieldQueryNode || text.length() <= 0) {
// Ignore empty terms
return node;
}
if (isWildcard(text)) {
Analyzer analyzer = getQueryConfigHandler().get(ConfigurationKeys.ANALYZER);
if (analyzer != null) {
text = analyzeWildcard(analyzer, fqn.getFieldAsString(), text.toString());
}
if (isPrefixWildcard(text)) {
return new PrefixWildcardQueryNode(fqn.getField(), text, fqn.getBegin(), fqn.getEnd());
} else {
return new WildcardQueryNode(fqn.getField(), text, fqn.getBegin(), fqn.getEnd());
}
}
}
return node;
}
use of org.apache.lucene.queryparser.flexible.standard.nodes.PrefixWildcardQueryNode in project lucene-solr by apache.
the class PrefixWildcardQueryNodeBuilder method build.
@Override
public PrefixQuery build(QueryNode queryNode) throws QueryNodeException {
PrefixWildcardQueryNode wildcardNode = (PrefixWildcardQueryNode) queryNode;
String text = wildcardNode.getText().subSequence(0, wildcardNode.getText().length() - 1).toString();
PrefixQuery q = new PrefixQuery(new Term(wildcardNode.getFieldAsString(), text));
MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod) queryNode.getTag(MultiTermRewriteMethodProcessor.TAG_ID);
if (method != null) {
q.setRewriteMethod(method);
}
return q;
}
Aggregations