當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。