當前位置: 首頁>>代碼示例>>Java>>正文


Java IndexReader.termDocs方法代碼示例

本文整理匯總了Java中org.apache.lucene.index.IndexReader.termDocs方法的典型用法代碼示例。如果您正苦於以下問題:Java IndexReader.termDocs方法的具體用法?Java IndexReader.termDocs怎麽用?Java IndexReader.termDocs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.lucene.index.IndexReader的用法示例。


在下文中一共展示了IndexReader.termDocs方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: locateContainer

import org.apache.lucene.index.IndexReader; //導入方法依賴的package包/類
protected boolean locateContainer(String nodeRef, IndexReader reader)
{
    boolean found = false;
    try
    {
        TermDocs td = reader.termDocs(new Term("ID", nodeRef));
        while (td.next())
        {
            int doc = td.doc();
            Document document = reader.document(doc);
            if (document.getField("ISCONTAINER") != null)
            {
                found = true;
                break;
            }
        }
        td.close();
    }
    catch (IOException e)
    {
        throw new LuceneIndexException("Failed to delete container and below for " + nodeRef, e);
    }
    return found;        
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:25,代碼來源:AbstractLuceneIndexerImpl.java

示例2: getDocIdSet

import org.apache.lucene.index.IndexReader; //導入方法依賴的package包/類
@Override
public DocIdSet getDocIdSet(IndexReader reader) throws IOException
{
	int max = reader.maxDoc();
	OpenBitSet good = new OpenBitSet(max);
	good.set(0, max);
	for( List<Field> values : terms )
	{
		for( Field nv : values )
		{
			Term term = new Term(nv.getField(), nv.getValue());
			TermDocs docs = reader.termDocs(term);
			while( docs.next() )
			{
				good.clear(docs.doc());
			}
			docs.close();
		}
	}
	return good;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:22,代碼來源:MustNotFilter.java

示例3: deletePrimary

import org.apache.lucene.index.IndexReader; //導入方法依賴的package包/類
protected static Set<String> deletePrimary(Collection<String> nodeRefs, IndexReader reader, boolean delete)
        throws LuceneIndexException
{

    Set<String> refs = new LinkedHashSet<String>();

    for (String nodeRef : nodeRefs)
    {

        try
        {
            TermDocs td = reader.termDocs(new Term("PRIMARYPARENT", nodeRef));
            while (td.next())
            {
                int doc = td.doc();
                Document document = reader.document(doc);
                String[] ids = document.getValues("ID");
                refs.add(ids[ids.length - 1]);
                if (delete)
                {
                    reader.deleteDocument(doc);
                }
            }
            td.close();
        }
        catch (IOException e)
        {
            throw new LuceneIndexException("Failed to delete node by primary parent for " + nodeRef, e);
        }
    }

    return refs;

}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:35,代碼來源:AbstractLuceneIndexerImpl.java

示例4: deleteReference

import org.apache.lucene.index.IndexReader; //導入方法依賴的package包/類
protected static Set<String> deleteReference(Collection<String> nodeRefs, IndexReader reader, boolean delete)
        throws LuceneIndexException
{

    Set<String> refs = new LinkedHashSet<String>();

    for (String nodeRef : nodeRefs)
    {

        try
        {
            TermDocs td = reader.termDocs(new Term("PARENT", nodeRef));
            while (td.next())
            {
                int doc = td.doc();
                Document document = reader.document(doc);
                String[] ids = document.getValues("ID");
                refs.add(ids[ids.length - 1]);
                if (delete)
                {
                    reader.deleteDocument(doc);
                }
            }
            td.close();
        }
        catch (IOException e)
        {
            throw new LuceneIndexException("Failed to delete node by parent for " + nodeRef, e);
        }
    }

    return refs;

}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:35,代碼來源:AbstractLuceneIndexerImpl.java

示例5: deleteContainerAndBelow

import org.apache.lucene.index.IndexReader; //導入方法依賴的package包/類
protected static Set<String> deleteContainerAndBelow(String nodeRef, IndexReader reader, boolean delete,
        boolean cascade) throws LuceneIndexException
{
    Set<String> refs = new LinkedHashSet<String>();

    try
    {
        if (delete)
        {
            reader.deleteDocuments(new Term("ID", nodeRef));
        }
        refs.add(nodeRef);
        if (cascade)
        {
            TermDocs td = reader.termDocs(new Term("ANCESTOR", nodeRef));
            while (td.next())
            {
                int doc = td.doc();
                Document document = reader.document(doc);
                String[] ids = document.getValues("ID");
                refs.add(ids[ids.length - 1]);
                if (delete)
                {
                    reader.deleteDocument(doc);
                }
            }
            td.close();
        }
    }
    catch (IOException e)
    {
        throw new LuceneIndexException("Failed to delete container and below for " + nodeRef, e);
    }
    return refs;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:36,代碼來源:AbstractLuceneIndexerImpl.java

示例6: scorer

import org.apache.lucene.index.IndexReader; //導入方法依賴的package包/類
public Scorer scorer(IndexReader reader) throws IOException {
  TermDocs termDocs = reader.termDocs(term);

  if (termDocs == null)
    return null;

  String field = term.field();
  return new TermScorer(this, termDocs, similarity,
          reader.hasNorms(field) ? reader.norms(field) : null);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:11,代碼來源:TermQuery.java

示例7: getDocIdSet

import org.apache.lucene.index.IndexReader; //導入方法依賴的package包/類
@Override
public DocIdSet getDocIdSet(IndexReader reader) throws IOException
{
	int max = reader.maxDoc();
	OpenBitSet good = new OpenBitSet(max);
	Institution institution = CurrentInstitution.get();
	Term term = new Term(FreeTextQuery.FIELD_INSTITUTION, Long.toString(institution.getUniqueId()));
	TermDocs docs = reader.termDocs(term);
	while( docs.next() )
	{
		good.set(docs.doc());
	}
	docs.close();
	return good;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:16,代碼來源:InstitutionFilter.java

示例8: 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.termDocs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。