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

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

java 1次浏览

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

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

示例1: testBasicDemo

点赞 2

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

示例2: QueryParserHelper

点赞 1

import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser; //导入依赖的package包/类
/**
 * Creates a query parser helper object using the specified configuration,
 * text parser, processor and builder.
 * 
 * @param queryConfigHandler
 *          the query configuration handler that will be initially set to this
 *          helper
 * @param syntaxParser
 *          the text parser that will be initially set to this helper
 * @param processor
 *          the query processor that will be initially set to this helper
 * @param builder
 *          the query builder that will be initially set to this helper
 * 
 * @see QueryNodeProcessor
 * @see SyntaxParser
 * @see QueryBuilder
 * @see QueryConfigHandler
 */
public QueryParserHelper(QueryConfigHandler queryConfigHandler, SyntaxParser syntaxParser, QueryNodeProcessor processor,
    QueryBuilder builder) {
  this.syntaxParser = syntaxParser;
  this.config = queryConfigHandler;
  this.processor = processor;
  this.builder = builder;

  if (processor != null) {
    processor.setQueryConfigHandler(queryConfigHandler);
  }

}
 

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

示例3: getSyntaxParser

点赞 1

import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser; //导入依赖的package包/类
/**
 * Returns the text parser used to build a query node tree from a query
 * string. The default text parser instance returned by this method is a
 * {@link SyntaxParser}.
 * 
 * @return the text parse used to build query node trees.
 * 
 * @see SyntaxParser
 * @see #setSyntaxParser(SyntaxParser)
 */
public SyntaxParser getSyntaxParser() {
  return this.syntaxParser;
}
 

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

示例4: setSyntaxParser

点赞 1

import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser; //导入依赖的package包/类
/**
 * Sets the text parser that will be used to parse the query string, it cannot
 * be <code>null</code>.
 * 
 * @param syntaxParser
 *          the text parser that will be used to parse the query string
 * 
 * @see #getSyntaxParser()
 * @see SyntaxParser
 */
public void setSyntaxParser(SyntaxParser syntaxParser) {

  if (syntaxParser == null) {
    throw new IllegalArgumentException("textParser should not be null!");
  }

  this.syntaxParser = syntaxParser;

}
 

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


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