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

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

java 1次浏览

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

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

示例1: StandardQueryTreeBuilder

点赞 3

import org.apache.lucene.queryparser.flexible.standard.nodes.NumericQueryNode; //导入依赖的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.NumericQueryNode; //导入依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
  
  if (node instanceof FieldQueryNode
      && !(node.getParent() instanceof RangeQueryNode)) {
    
    QueryConfigHandler config = getQueryConfigHandler();
    
    if (config != null) {
      FieldQueryNode fieldNode = (FieldQueryNode) node;
      FieldConfig fieldConfig = config.getFieldConfig(fieldNode
          .getFieldAsString());
      
      if (fieldConfig != null) {
        NumericConfig numericConfig = fieldConfig
            .get(ConfigurationKeys.NUMERIC_CONFIG);
        
        if (numericConfig != null) {
          
          NumberFormat numberFormat = numericConfig.getNumberFormat();
          String text = fieldNode.getTextAsString();
          Number number = null;
          
          if (text.length() > 0) {
            
            try {
              number = numberFormat.parse(text);
              
            } catch (ParseException e) {
              throw new QueryNodeParseException(new MessageImpl(
                  QueryParserMessages.COULD_NOT_PARSE_NUMBER, fieldNode
                      .getTextAsString(), numberFormat.getClass()
                      .getCanonicalName()), e);
            }
            
            switch (numericConfig.getType()) {
              case LONG:
                number = number.longValue();
                break;
              case INT:
                number = number.intValue();
                break;
              case DOUBLE:
                number = number.doubleValue();
                break;
              case FLOAT:
                number = number.floatValue();
            }
            
          } else {
            throw new QueryNodeParseException(new MessageImpl(
                QueryParserMessages.NUMERIC_CANNOT_BE_EMPTY, fieldNode.getFieldAsString()));
          }
          
          NumericQueryNode lowerNode = new NumericQueryNode(fieldNode
              .getField(), number, numberFormat);
          NumericQueryNode upperNode = new NumericQueryNode(fieldNode
              .getField(), number, numberFormat);
          
          return new NumericRangeQueryNode(lowerNode, upperNode, true, true,
              numericConfig);
          
        }
        
      }
      
    }
    
  }
  
  return node;
  
}
 

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

示例3: build

点赞 2

import org.apache.lucene.queryparser.flexible.standard.nodes.NumericQueryNode; //导入依赖的package包/类
@Override
public NumericRangeQuery<? extends Number> build(QueryNode queryNode)
    throws QueryNodeException {
  NumericRangeQueryNode numericRangeNode = (NumericRangeQueryNode) queryNode;
  
  NumericQueryNode lowerNumericNode = numericRangeNode.getLowerBound();
  NumericQueryNode upperNumericNode = numericRangeNode.getUpperBound();
  
  Number lowerNumber = lowerNumericNode.getValue();
  Number upperNumber = upperNumericNode.getValue();
  
  NumericConfig numericConfig = numericRangeNode.getNumericConfig();
  NumericType numberType = numericConfig.getType();
  String field = StringUtils.toString(numericRangeNode.getField());
  boolean minInclusive = numericRangeNode.isLowerInclusive();
  boolean maxInclusive = numericRangeNode.isUpperInclusive();
  int precisionStep = numericConfig.getPrecisionStep();
  
  switch (numberType) {
    
    case LONG:
      return NumericRangeQuery.newLongRange(field, precisionStep,
          (Long) lowerNumber, (Long) upperNumber, minInclusive, maxInclusive);
    
    case INT:
      return NumericRangeQuery.newIntRange(field, precisionStep,
          (Integer) lowerNumber, (Integer) upperNumber, minInclusive,
          maxInclusive);
    
    case FLOAT:
      return NumericRangeQuery.newFloatRange(field, precisionStep,
          (Float) lowerNumber, (Float) upperNumber, minInclusive,
          maxInclusive);
    
    case DOUBLE:
      return NumericRangeQuery.newDoubleRange(field, precisionStep,
          (Double) lowerNumber, (Double) upperNumber, minInclusive,
          maxInclusive);
      
      default :
        throw new QueryNodeException(new MessageImpl(
          QueryParserMessages.UNSUPPORTED_NUMERIC_DATA_TYPE, numberType));
      
  }
}
 

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


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