• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TermRangeQueryNode类的典型用法和代码示例

java 8次浏览

本文整理汇总了Java中org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode的典型用法代码示例。如果您正苦于以下问题:Java TermRangeQueryNode类的具体用法?Java TermRangeQueryNode怎么用?Java TermRangeQueryNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TermRangeQueryNode类属于org.apache.lucene.queryparser.flexible.standard.nodes包,在下文中一共展示了TermRangeQueryNode类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: StandardQueryTreeBuilder

点赞 3

import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; //导入依赖的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());
  
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:24,
代码来源:StandardQueryTreeBuilder.java

示例2: postProcessNode

点赞 2

import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; //导入依赖的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;

}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:35,
代码来源:WildcardQueryNodeProcessor.java

示例3: postProcessNode

点赞 2

import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; //导入依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
  
  if (node instanceof TermRangeQueryNode) {
    TermRangeQueryNode rangeNode = (TermRangeQueryNode) node;
    FieldQueryNode lowerNode = rangeNode.getLowerBound();
    FieldQueryNode upperNode = rangeNode.getUpperBound();
    CharSequence lowerText = lowerNode.getText();
    CharSequence upperText = upperNode.getText();
    
    if (OPEN_RANGE_TOKEN.equals(upperNode.getTextAsString())
        && (!(upperText instanceof UnescapedCharSequence) || !((UnescapedCharSequence) upperText)
            .wasEscaped(0))) {
      upperText = "";
    }
    
    if (OPEN_RANGE_TOKEN.equals(lowerNode.getTextAsString())
        && (!(lowerText instanceof UnescapedCharSequence) || !((UnescapedCharSequence) lowerText)
            .wasEscaped(0))) {
      lowerText = "";
    }
    
    lowerNode.setText(lowerText);
    upperNode.setText(upperText);
  }
  
  return node;
  
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:30,
代码来源:OpenRangeQueryNodeProcessor.java

示例4: build

点赞 2

import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; //导入依赖的package包/类
@Override
public TermRangeQuery build(QueryNode queryNode) throws QueryNodeException {
  TermRangeQueryNode rangeNode = (TermRangeQueryNode) queryNode;
  FieldQueryNode upper = rangeNode.getUpperBound();
  FieldQueryNode lower = rangeNode.getLowerBound();
  
  String field = StringUtils.toString(rangeNode.getField());
  String lowerText = lower.getTextAsString();
  String upperText = upper.getTextAsString();
  
  if (lowerText.length() == 0) {
    lowerText = null;
  }
  
  if (upperText.length() == 0) {
    upperText = null;
  }
  
  TermRangeQuery rangeQuery = TermRangeQuery.newStringRange(field, lowerText, upperText, rangeNode
      .isLowerInclusive(), rangeNode.isUpperInclusive());
  
  MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod) queryNode
      .getTag(MultiTermRewriteMethodProcessor.TAG_ID);
  if (method != null) {
    rangeQuery.setRewriteMethod(method);
  }
  
  return rangeQuery;
  
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:31,
代码来源:TermRangeQueryNodeBuilder.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)