本文整理汇总了Java中org.apache.lucene.index.IndexReader.terms方法的典型用法代码示例。如果您正苦于以下问题:Java IndexReader.terms方法的具体用法?Java IndexReader.terms怎么用?Java IndexReader.terms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.index.IndexReader
的用法示例。
在下文中一共展示了IndexReader.terms方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expand
import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
/**
* Create a list of term arrays of no larger than 1024 (Default {@link
* BooleanQuery.maxClauseCount()} for boolean queries)
*/
public Term[] expand(IndexReader ir, String field, String prefix) throws IOException
{
if( prefix.isEmpty() )
{
return new Term[0];
}
ArrayList<Term> terms = Lists.newArrayList();
try( TermEnum t = ir.terms(new Term(field, prefix)) )
{
do
{
if( t.term().text().startsWith(prefix) )
{
terms.add(t.term());
}
else
{
break;
}
}
while( t.next() );
}
return terms.toArray(new Term[terms.size()]);
}
示例2: queryTerms
import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
@Override
public <T> void queryTerms(
@NonNull Collection<? super T> result,
@NullAllowed Term start,
@NonNull StoppableConvertor<Term, T> filter,
@NullAllowed AtomicBoolean cancel) throws IOException, InterruptedException {
Parameters.notNull("result", result); //NOI18N
Parameters.notNull("filter", filter); //NOI18N
lock.readLock().lock();
try {
final IndexReader in = getReader();
if (in == null) {
return;
}
final TermEnum terms = start == null ? in.terms () : in.terms (start);
try {
do {
if (cancel != null && cancel.get()) {
throw new InterruptedException ();
}
final Term currentTerm = terms.term();
if (currentTerm != null) {
final T vote = filter.convert(currentTerm);
if (vote != null) {
result.add(vote);
}
}
} while (terms.next());
} catch (StoppableConvertor.Stop stop) {
//Stop iteration of TermEnum
} finally {
terms.close();
}
} finally {
lock.readLock().unlock();
}
}
示例3: XPathFieldIterator
import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
public XPathFieldIterator(IndexReader reader, String field, String start) throws IOException
{
int hasIndex = field.indexOf('[');
if( hasIndex >= 0 )
{
pattern = Pattern.compile(field.replaceAll("\\[\\]", "(\\\\[\\\\d*\\\\])?") + "/\\$XPATH\\$");
field = field.substring(0, hasIndex);
}
enumerator = reader.terms(new Term(field, start));
current = enumerator.term();
this.field = field;
findNextMatch();
}
示例4: FieldIterator
import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
public FieldIterator(IndexReader reader, String field, String start) throws IOException
{
this.field = field;
enumerator = reader.terms(new Term(field, start));
current = enumerator.term();
checkSameField();
}
示例5: getDocIdSet
import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
@Override
public DocIdSet getDocIdSet(IndexReader reader) throws IOException
{
OpenBitSet bits = new OpenBitSet(reader.maxDoc());
Term startTerm = new Term(field, start);
Term endTerm = new Term(field, end);
TermEnum enumerator = reader.terms(startTerm);
if( enumerator.term() == null )
{
return bits;
}
TermDocs termDocs = reader.termDocs();
try
{
Term current = enumerator.term();
while( current.compareTo(endTerm) <= 0 )
{
termDocs.seek(enumerator.term());
while( termDocs.next() )
{
bits.set(termDocs.doc());
}
if( !enumerator.next() )
{
break;
}
current = enumerator.term();
}
}
finally
{
enumerator.close();
termDocs.close();
}
return bits;
}