本文整理汇总了Java中org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode类的典型用法代码示例。如果您正苦于以下问题:Java WildcardQueryNode类的具体用法?Java WildcardQueryNode怎么用?Java WildcardQueryNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WildcardQueryNode类属于org.apache.lucene.queryparser.flexible.standard.nodes包,在下文中一共展示了WildcardQueryNode类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postProcessNode
import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode; //导入依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
Locale locale = getQueryConfigHandler().get(ConfigurationKeys.LOCALE);
if (locale == null) {
locale = Locale.getDefault();
}
if (node instanceof WildcardQueryNode
|| node instanceof FuzzyQueryNode
|| (node instanceof FieldQueryNode && node.getParent() instanceof RangeQueryNode)
|| node instanceof RegexpQueryNode) {
TextableQueryNode txtNode = (TextableQueryNode) node;
CharSequence text = txtNode.getText();
txtNode.setText(text != null ? UnescapedCharSequence.toLowerCase(text, locale) : null);
}
return node;
}
示例2: postProcessNode
import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode; //导入依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
if (node instanceof WildcardQueryNode) {
WildcardQueryNode wildcardNode = (WildcardQueryNode) node;
if (wildcardNode.getText().length() > 0) {
// Validate if the wildcard was escaped
if (UnescapedCharSequence.wasEscaped(wildcardNode.getText(), 0))
return node;
switch (wildcardNode.getText().charAt(0)) {
case '*':
case '?':
throw new QueryNodeException(new MessageImpl(
QueryParserMessages.LEADING_WILDCARD_NOT_ALLOWED, node
.toQueryString(new EscapeQuerySyntaxImpl())));
}
}
}
return node;
}
示例3: postProcessNode
import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode; //导入依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) {
// set setMultiTermRewriteMethod for WildcardQueryNode and
// PrefixWildcardQueryNode
if (node instanceof WildcardQueryNode
|| node instanceof AbstractRangeQueryNode || node instanceof RegexpQueryNode) {
MultiTermQuery.RewriteMethod rewriteMethod = getQueryConfigHandler().get(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD);
if (rewriteMethod == null) {
// This should not happen, this configuration is set in the
// StandardQueryConfigHandler
throw new IllegalArgumentException(
"StandardQueryConfigHandler.ConfigurationKeys.MULTI_TERM_REWRITE_METHOD should be set on the QueryConfigHandler");
}
// use a TAG to take the value to the Builder
node.setTag(MultiTermRewriteMethodProcessor.TAG_ID, rewriteMethod);
}
return node;
}
示例4: StandardQueryTreeBuilder
import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode; //导入依赖的package包/类
public StandardQueryTreeBuilder() {
setBuilder(GroupQueryNode.class, new GroupQueryNodeBuilder());
setBuilder(FieldQueryNode.class, new FieldQueryNodeBuilder());
setBuilder(BooleanQueryNode.class, new BooleanQueryNodeBuilder());
setBuilder(FuzzyQueryNode.class, new FuzzyQueryNodeBuilder());
setBuilder(NumericQueryNode.class, new DummyQueryNodeBuilder());
setBuilder(NumericRangeQueryNode.class, new NumericRangeQueryNodeBuilder());
setBuilder(BoostQueryNode.class, new BoostQueryNodeBuilder());
setBuilder(ModifierQueryNode.class, new ModifierQueryNodeBuilder());
setBuilder(WildcardQueryNode.class, new WildcardQueryNodeBuilder());
setBuilder(TokenizedPhraseQueryNode.class, new PhraseQueryNodeBuilder());
setBuilder(MatchNoDocsQueryNode.class, new MatchNoDocsQueryNodeBuilder());
setBuilder(PrefixWildcardQueryNode.class,
new PrefixWildcardQueryNodeBuilder());
setBuilder(TermRangeQueryNode.class, new TermRangeQueryNodeBuilder());
setBuilder(RegexpQueryNode.class, new RegexpQueryNodeBuilder());
setBuilder(SlopQueryNode.class, new SlopQueryNodeBuilder());
setBuilder(StandardBooleanQueryNode.class,
new StandardBooleanQueryNodeBuilder());
setBuilder(MultiPhraseQueryNode.class, new MultiPhraseQueryNodeBuilder());
setBuilder(MatchAllDocsQueryNode.class, new MatchAllDocsQueryNodeBuilder());
}
示例5: postProcessNode
import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode; //导入依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
// the old Lucene Parser ignores FuzzyQueryNode that are also PrefixWildcardQueryNode or WildcardQueryNode
// we do the same here, also ignore empty terms
if (node instanceof FieldQueryNode || node instanceof FuzzyQueryNode) {
FieldQueryNode fqn = (FieldQueryNode) node;
CharSequence text = fqn.getText();
// do not process wildcards for TermRangeQueryNode children and
// QuotedFieldQueryNode to reproduce the old parser behavior
if (fqn.getParent() instanceof TermRangeQueryNode
|| fqn instanceof QuotedFieldQueryNode
|| text.length() <= 0){
// Ignore empty terms
return node;
}
// Code below simulates the old lucene parser behavior for wildcards
if (isPrefixWildcard(text)) {
PrefixWildcardQueryNode prefixWildcardQN = new PrefixWildcardQueryNode(fqn);
return prefixWildcardQN;
} else if (isWildcard(text)){
WildcardQueryNode wildcardQN = new WildcardQueryNode(fqn);
return wildcardQN;
}
}
return node;
}
示例6: build
import org.apache.lucene.queryparser.flexible.standard.nodes.WildcardQueryNode; //导入依赖的package包/类
@Override
public WildcardQuery build(QueryNode queryNode) throws QueryNodeException {
WildcardQueryNode wildcardNode = (WildcardQueryNode) queryNode;
WildcardQuery q = new WildcardQuery(new Term(wildcardNode.getFieldAsString(),
wildcardNode.getTextAsString()));
MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodProcessor.TAG_ID);
if (method != null) {
q.setRewriteMethod(method);
}
return q;
}