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


Java PrefixTermsEnum类代码示例

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


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

示例1: getTermsEnum

import org.apache.lucene.search.PrefixTermsEnum; //导入依赖的package包/类
/** Return a {@link TermsEnum} intersecting the provided {@link Terms}
 *  with the terms accepted by this automaton. */
public TermsEnum getTermsEnum(Terms terms) throws IOException {
  switch(type) {
  case NONE:
    return TermsEnum.EMPTY;
  case ALL:
    return terms.iterator(null);
  case SINGLE:
    return new SingleTermsEnum(terms.iterator(null), term);
  case PREFIX:
    // TODO: this is very likely faster than .intersect,
    // but we should test and maybe cutover
    return new PrefixTermsEnum(terms.iterator(null), term);
  case NORMAL:
    return terms.intersect(this, null);
  default:
    // unreachable
    throw new RuntimeException("unhandled case");
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:CompiledAutomaton.java

示例2: getTermsEnum

import org.apache.lucene.search.PrefixTermsEnum; //导入依赖的package包/类
public TermsEnum getTermsEnum(Terms terms) throws IOException {
  switch(type) {
  case NONE:
    return TermsEnum.EMPTY;
  case ALL:
    return terms.iterator(null);
  case SINGLE:
    return new SingleTermsEnum(terms.iterator(null), term);
  case PREFIX:
    // TODO: this is very likely faster than .intersect,
    // but we should test and maybe cutover
    return new PrefixTermsEnum(terms.iterator(null), term);
  case NORMAL:
    return terms.intersect(this, null);
  default:
    // unreachable
    throw new RuntimeException("unhandled case");
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:CompiledAutomaton.java

示例3: getOptions

import org.apache.lucene.search.PrefixTermsEnum; //导入依赖的package包/类
private Suggest.Suggestion.Entry<Suggest.Suggestion.Entry.Option> getOptions(Term text, PrefixTermsEnum prefixTermsEnum, IndexReader indexReader, final int size) throws IOException {
    OptionQueue collectionQueue =  new OptionQueue(size);
    BytesRef ref;
    while ((ref = prefixTermsEnum.next()) != null) {
        Term term = new Term(text.field(), BytesRef.deepCopyOf(ref));
        collectionQueue.insertWithOverflow(new Suggest.Suggestion.Entry.Option(new StringText(term.bytes().utf8ToString()), indexReader.docFreq(term)));
    }

    Suggest.Suggestion.Entry<Suggest.Suggestion.Entry.Option> entry = new Suggest.Suggestion.Entry<Suggest.Suggestion.Entry.Option>(new StringText(text.text()),0, text.bytes().length );
    while(collectionQueue.size() > 0){
        entry.addOption(collectionQueue.pop());
    }
    return entry;
}
 
开发者ID:meltwater,项目名称:es-prefix-suggester,代码行数:15,代码来源:PrefixSuggester.java


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