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


Java IndexReader.terms方法代码示例

本文整理汇总了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()]);
}
 
开发者ID:equella,项目名称:Equella,代码行数:30,代码来源:ItemIndex.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:MemoryIndex.java

示例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();
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:XPathFieldIterator.java

示例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();
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:FieldIterator.java

示例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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:43,代码来源:ComparisonFilter.java


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