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


Java StandardQueryConfigHandler类代码示例

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


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

示例1: testStopWordSearching

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
public void testStopWordSearching() throws Exception {
  Analyzer analyzer = new MockAnalyzer(random());
  Directory ramDir = newDirectory();
  IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(analyzer));
  Document doc = new Document();
  doc.add(newTextField("body", "blah the footest blah", Field.Store.NO));
  iw.addDocument(doc);
  iw.close();

  StandardQueryParser mfqp = new StandardQueryParser();

  mfqp.setMultiFields(new String[] { "body" });
  mfqp.setAnalyzer(analyzer);
  mfqp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
  Query q = mfqp.parse("the footest", null);
  IndexReader ir = DirectoryReader.open(ramDir);
  IndexSearcher is = newSearcher(ir);
  ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
  assertEquals(1, hits.length);
  ir.close();
  ramDir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:TestMultiFieldQPHelper.java

示例2: testStopWordSearching

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
public void testStopWordSearching() throws Exception {
  Analyzer analyzer = new MockAnalyzer(random());
  Directory ramDir = newDirectory();
  IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
  Document doc = new Document();
  doc.add(newTextField("body", "blah the footest blah", Field.Store.NO));
  iw.addDocument(doc);
  iw.close();

  StandardQueryParser mfqp = new StandardQueryParser();

  mfqp.setMultiFields(new String[] { "body" });
  mfqp.setAnalyzer(analyzer);
  mfqp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
  Query q = mfqp.parse("the footest", null);
  IndexReader ir = DirectoryReader.open(ramDir);
  IndexSearcher is = new IndexSearcher(ir);
  ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
  assertEquals(1, hits.length);
  ir.close();
  ramDir.close();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:23,代码来源:TestMultiFieldQPHelper.java

示例3: testStopWordSearching

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
public void testStopWordSearching() throws Exception {
  Analyzer analyzer = new MockAnalyzer(random());
  Directory ramDir = newDirectory();
  IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
  Document doc = new Document();
  doc.add(newTextField("body", "blah the footest blah", Field.Store.NO));
  iw.addDocument(doc);
  iw.close();

  StandardQueryParser mfqp = new StandardQueryParser();

  mfqp.setMultiFields(new String[] { "body" });
  mfqp.setAnalyzer(analyzer);
  mfqp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
  Query q = mfqp.parse("the footest", null);
  IndexReader ir = DirectoryReader.open(ramDir);
  IndexSearcher is = newSearcher(ir);
  ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
  assertEquals(1, hits.length);
  ir.close();
  ramDir.close();
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:23,代码来源:TestMultiFieldQPHelper.java

示例4: getKeywords

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
public static List<String> getKeywords(final String q, final String[] fields) {
    final List<String> keywords = new ArrayList<>();
    final List<TermQuery> termQueryList;
    try {
        final StandardQueryParser parser = new StandardQueryParser();
        parser.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);

        termQueryList = getTermQueryList(parser.parse(q, "default"), fields);
    } catch (final Exception e) {
        return keywords;
    }
    for (final TermQuery tq : termQueryList) {
        final String text = tq.getTerm().text();
        if (0 == text.length()) {
            continue;
        }
        if (keywords.contains(text)) {
            continue;
        }
        keywords.add(text);
    }
    return keywords;
}
 
开发者ID:codelibs,项目名称:fess-suggest,代码行数:24,代码来源:SuggestUtil.java

示例5: process

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
@Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException {
  Operator op = getQueryConfigHandler().get(ConfigurationKeys.DEFAULT_OPERATOR);
  
  if (op == null) {
    throw new IllegalArgumentException(
        "StandardQueryConfigHandler.ConfigurationKeys.DEFAULT_OPERATOR should be set on the QueryConfigHandler");
  }

  this.usingAnd = StandardQueryConfigHandler.Operator.AND == op;

  return super.process(queryTree);

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

示例6: process

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
@Override
public QueryNode process(QueryNode queryTree) throws QueryNodeException {
  Operator op = getQueryConfigHandler().get(
      ConfigurationKeys.DEFAULT_OPERATOR);
  
  if (op == null) {
    throw new IllegalArgumentException(
        "StandardQueryConfigHandler.ConfigurationKeys.DEFAULT_OPERATOR should be set on the QueryConfigHandler");
  }
  
  this.usingAnd = StandardQueryConfigHandler.Operator.AND == op;
  
  return processIteration(queryTree);
  
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:BooleanQuery2ModifierNodeProcessor.java

示例7: StandardQueryParser

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
/**
 * Constructs a {@link StandardQueryParser} object.
 */
public StandardQueryParser() {
  super(new StandardQueryConfigHandler(), new StandardSyntaxParser(),
      new StandardQueryNodeProcessorPipeline(null),
      new StandardQueryTreeBuilder());
  setEnablePositionIncrements(true);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:StandardQueryParser.java

示例8: getParser

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
public PrecedenceQueryParser getParser(Analyzer a) throws Exception {
  if (a == null)
    a = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
  PrecedenceQueryParser qp = new PrecedenceQueryParser();
  qp.setAnalyzer(a);
  qp.setDefaultOperator(StandardQueryConfigHandler.Operator.OR);
  return qp;
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TestPrecedenceQueryParser.java

示例9: getQueryDOA

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
public Query getQueryDOA(String query, Analyzer a) throws Exception {
  if (a == null)
    a = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
  PrecedenceQueryParser qp = new PrecedenceQueryParser();
  qp.setAnalyzer(a);
  qp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);
  return qp.parse(query, "field");
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TestPrecedenceQueryParser.java

示例10: testDefaultOperator

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
@Override
public void testDefaultOperator() throws Exception {
  StandardQueryParser qp = getParser(new MockAnalyzer(random()));
  // make sure OR is the default:
  assertEquals(StandardQueryConfigHandler.Operator.OR, qp.getDefaultOperator());
  setDefaultOperatorAND(qp);
  assertEquals(StandardQueryConfigHandler.Operator.AND, qp.getDefaultOperator());
  setDefaultOperatorOR(qp);
  assertEquals(StandardQueryConfigHandler.Operator.OR, qp.getDefaultOperator());
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:TestStandardQP.java

示例11: getParser

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
public StandardQueryParser getParser(Analyzer a) throws Exception {
  if (a == null)
    a = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
  StandardQueryParser qp = new StandardQueryParser();
  qp.setAnalyzer(a);

  qp.setDefaultOperator(StandardQueryConfigHandler.Operator.OR);

  return qp;

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

示例12: getQueryDOA

import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler; //导入依赖的package包/类
public Query getQueryDOA(String query, Analyzer a) throws Exception {
  if (a == null)
    a = new MockAnalyzer(random(), MockTokenizer.SIMPLE, true);
  StandardQueryParser qp = new StandardQueryParser();
  qp.setAnalyzer(a);
  qp.setDefaultOperator(StandardQueryConfigHandler.Operator.AND);

  return qp.parse(query, "field");

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


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