本文整理汇总了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");
}
}
示例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");
}
}
示例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;
}