当前位置: 首页>>代码示例>>Java>>正文


Java QueryConfigHandler类代码示例

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


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

示例1: StandardQueryNodeProcessorPipeline

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
public StandardQueryNodeProcessorPipeline(QueryConfigHandler queryConfig) {
  super(queryConfig);

  add(new WildcardQueryNodeProcessor());    
  add(new MultiFieldQueryNodeProcessor());
  add(new FuzzyQueryNodeProcessor());
  add(new MatchAllDocsQueryNodeProcessor());
  add(new OpenRangeQueryNodeProcessor());
  add(new NumericQueryNodeProcessor());
  add(new NumericRangeQueryNodeProcessor());
  add(new LowercaseExpandedTermsQueryNodeProcessor());
  add(new TermRangeQueryNodeProcessor());
  add(new AllowLeadingWildcardProcessor());    
  add(new AnalyzerQueryNodeProcessor());
  add(new PhraseSlopQueryNodeProcessor());
  //add(new GroupQueryNodeProcessor());
  add(new BooleanQuery2ModifierNodeProcessor());
  add(new NoChildOptimizationQueryNodeProcessor());
  add(new RemoveDeletedQueryNodesProcessor());
  add(new RemoveEmptyNonLeafQueryNodeProcessor());
  add(new BooleanSingleChildOptimizationQueryNodeProcessor());
  add(new DefaultPhraseSlopQueryNodeProcessor());
  add(new BoostQueryNodeProcessor());    
  add(new MultiTermRewriteMethodProcessor());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:StandardQueryNodeProcessorPipeline.java

示例2: preProcessNode

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
@Override
protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {

  if (node instanceof FieldableNode) {
    FieldableNode fieldNode = (FieldableNode) node;

    QueryConfigHandler queryConfig = getQueryConfigHandler();

    if (queryConfig == null) {
      throw new IllegalArgumentException(
          "A config handler is expected by the processor UniqueFieldQueryNodeProcessor!");
    }

    if (!queryConfig.has(SpansQueryConfigHandler.UNIQUE_FIELD)) {
      throw new IllegalArgumentException(
          "UniqueFieldAttribute should be defined in the config handler!");
    }

    String uniqueField = queryConfig.get(SpansQueryConfigHandler.UNIQUE_FIELD);
    fieldNode.setField(uniqueField);

  }

  return node;

}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:UniqueFieldQueryNodeProcessor.java

示例3: setQueryConfigHandler

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
/**
 * For reference about this method check:
 * {@link QueryNodeProcessor#setQueryConfigHandler(QueryConfigHandler)}.
 * 
 * @param queryConfigHandler the query configuration handler to be set.
 * 
 * @see QueryNodeProcessor#getQueryConfigHandler()
 * @see QueryConfigHandler
 */
@Override
public void setQueryConfigHandler(QueryConfigHandler queryConfigHandler) {
  this.queryConfig = queryConfigHandler;

  for (QueryNodeProcessor processor : this.processors) {
    processor.setQueryConfigHandler(this.queryConfig);
  }

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

示例4: testBasicDemo

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
public void testBasicDemo() throws Exception {
  SyntaxParser queryParser = new StandardSyntaxParser();

  // convert the CharSequence into a QueryNode tree
  QueryNode queryTree = queryParser.parse("body:text", null);

  // create a config handler with a attribute used in
  // UniqueFieldQueryNodeProcessor
  QueryConfigHandler spanQueryConfigHandler = new SpansQueryConfigHandler();
  spanQueryConfigHandler.set(SpansQueryConfigHandler.UNIQUE_FIELD, "index");

  // set up the processor pipeline with the ConfigHandler
  // and create the pipeline for this simple demo
  QueryNodeProcessorPipeline spanProcessorPipeline = new QueryNodeProcessorPipeline(
      spanQueryConfigHandler);
  // @see SpansValidatorQueryNodeProcessor
  spanProcessorPipeline.add(new SpansValidatorQueryNodeProcessor());
  // @see UniqueFieldQueryNodeProcessor
  spanProcessorPipeline.add(new UniqueFieldQueryNodeProcessor());

  // print to show out the QueryNode tree before being processed
  if (VERBOSE) System.out.println(queryTree);

  // Process the QueryTree using our new Processors
  queryTree = spanProcessorPipeline.process(queryTree);

  // print to show out the QueryNode tree after being processed
  if (VERBOSE) System.out.println(queryTree);

  // create a instance off the Builder
  SpansQueryTreeBuilder spansQueryTreeBuilder = new SpansQueryTreeBuilder();

  // convert QueryNode tree to span query Objects
  SpanQuery spanquery = spansQueryTreeBuilder.build(queryTree);

  assertTrue(spanquery instanceof SpanTermQuery);
  assertEquals(spanquery.toString(), "index:text");

}
 
开发者ID:europeana,项目名称:search,代码行数:40,代码来源:TestSpanQueryParserSimpleSample.java

示例5: postProcessNode

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的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

示例6: getQueryConfigHandler

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
@Override
public QueryConfigHandler getQueryConfigHandler() {
  return this.queryConfig;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:GroupQueryNodeProcessor.java

示例7: setQueryConfigHandler

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
@Override
public void setQueryConfigHandler(QueryConfigHandler queryConfigHandler) {
  this.queryConfig = queryConfigHandler;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:GroupQueryNodeProcessor.java

示例8: preProcessNode

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
@Override
protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {

  if (node instanceof FuzzyQueryNode) {
    FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) node;
    QueryConfigHandler config = getQueryConfigHandler();

    FuzzyConfig fuzzyConfig = null;
    
    if (config != null && (fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG)) != null) {
      fuzzyNode.setPrefixLength(fuzzyConfig.getPrefixLength());

      if (fuzzyNode.getSimilarity() < 0) {
        fuzzyNode.setSimilarity(fuzzyConfig.getMinSimilarity());
      }
      
    } else if (fuzzyNode.getSimilarity() < 0) {
      throw new IllegalArgumentException("No FUZZY_CONFIG set in the config");
    }

  }

  return node;

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

示例9: setQueryConfigHandler

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
@Override
public void setQueryConfigHandler(QueryConfigHandler queryConfigHandler) {
  this.queryConfigHandler = queryConfigHandler;
  
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:BooleanQuery2ModifierNodeProcessor.java

示例10: getQueryConfigHandler

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
@Override
public QueryConfigHandler getQueryConfigHandler() {
  return queryConfigHandler;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:BooleanQuery2ModifierNodeProcessor.java

示例11: process

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
@Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException {
  QueryConfigHandler queryConfig = getQueryConfigHandler();

  if (queryConfig != null) {
    Integer defaultPhraseSlop = queryConfig.get(ConfigurationKeys.PHRASE_SLOP); 
    
    if (defaultPhraseSlop != null) {
      this.defaultPhraseSlop = defaultPhraseSlop;

      return super.process(queryTree);

    }

  }

  return queryTree;

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

示例12: FieldDateResolutionFCListener

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
public FieldDateResolutionFCListener(QueryConfigHandler config) {
  this.config = config;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:FieldDateResolutionFCListener.java

示例13: FieldBoostMapFCListener

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
public FieldBoostMapFCListener(QueryConfigHandler config) {
  this.config = config;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:FieldBoostMapFCListener.java

示例14: QueryNodeProcessorImpl

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
public QueryNodeProcessorImpl(QueryConfigHandler queryConfigHandler) {
  this.queryConfig = queryConfigHandler;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:QueryNodeProcessorImpl.java

示例15: QueryNodeProcessorPipeline

import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入依赖的package包/类
/**
 * Constructs with a {@link QueryConfigHandler} object.
 */
public QueryNodeProcessorPipeline(QueryConfigHandler queryConfigHandler) {
  this.queryConfig = queryConfigHandler;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:QueryNodeProcessorPipeline.java


注:本文中的org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。