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


Java TermDocs.close方法代码示例

本文整理汇总了Java中org.apache.lucene.index.TermDocs.close方法的典型用法代码示例。如果您正苦于以下问题:Java TermDocs.close方法的具体用法?Java TermDocs.close怎么用?Java TermDocs.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.index.TermDocs的用法示例。


在下文中一共展示了TermDocs.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: locateContainer

import org.apache.lucene.index.TermDocs; //导入方法依赖的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.TermDocs; //导入方法依赖的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: queryFieldByUuid

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
/**
 * Returns the field values associated with a document
 * @param context the operation context
 * @param fieldName the field name
 * @param uuid the document uuid
 * @return the field values (null if not found)
 * @throws CorruptIndexException if the index is corrupt
 * @throws IOException if an I/O exception occurs
 */
public String[] queryFieldByUuid(TocContext context, String fieldName, String uuid) 
  throws CorruptIndexException, IOException {
  TermDocs termDocs = null;
  try {
    uuid = Val.chkStr(uuid);
    if (uuid.length() > 0) {
      IndexSearcher searcher = this.getSearcher(context);
      IndexReader reader = searcher.getIndexReader();
      MapFieldSelector selector = new MapFieldSelector(new String[]{fieldName});
      termDocs = reader.termDocs();
      termDocs.seek(new Term(Storeables.FIELD_UUID,uuid));
      if (termDocs.next()) {
        Document document = reader.document(termDocs.doc(),selector);
        return document.getValues(fieldName);
      }
    }
  } finally {
    try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
  }
  return null;
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:31,代码来源:TocIndexAdapter.java

示例4: queryValues

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
/**
 * Queries for documents that match one or more of the supplied values.
 * @param reader the index reader
 * @return the OpenBitSet (documents with matches are set to true)
 * @throws IOException if an exception is encountered while reading the index
 */
private OpenBitSet queryValues(IndexReader reader, String field, String[] values) throws IOException {
  OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
  if ((values != null) && (values.length > 0)) {
    TermDocs termDocs = null;
    try {      
      Term baseTerm = new Term(field);
      termDocs = reader.termDocs();
      for (String value: values) {
        termDocs.seek(baseTerm.createTerm(value.trim().toLowerCase()));
        while (termDocs.next()) {
          bitSet.set(termDocs.doc());
        }
      }
    } finally {
      try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
    }
  }
  return bitSet;
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:26,代码来源:AclFilter.java

示例5: queryValue

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
/**
 * Queries for documents that match the supplied value.
 * @param reader the index reader
 * @return the OpenBitSet (documents with matches are set to true)
 * @throws IOException if an exception is encountered while reading the index
 */
private OpenBitSet queryValue(IndexReader reader, String field, String value) throws IOException {
  OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
  if ((value != null) && (value.length() > 0)) {
    TermDocs termDocs = null;
    try {      
      Term term = new Term(field,value);
      termDocs = reader.termDocs();
      termDocs.seek(term);
      while (termDocs.next()) {
        bitSet.set(termDocs.doc());
      }
    } finally {
      try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
    }
  }
  return bitSet;
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:24,代码来源:SchemaFilter.java

示例6: queryValue

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
/**
 * Queries for documents that match the supplied value.
 * @param reader the index reader
 * @return the OpenBitSet (documents with matches are set to true)
 * @throws IOException if an exception is encountered while reading the index
 */
private OpenBitSet queryValue(IndexReader reader) throws IOException {
  OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
  if ((this.value != null) && (this.value.length() > 0)) {
    TermDocs termDocs = null;
    try {      
      Term term = new Term(this.fieldName,this.value);
      termDocs = reader.termDocs();
      termDocs.seek(term);
      while (termDocs.next()) {
        bitSet.set(termDocs.doc());
      }
    } finally {
      try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
    }
  }
  return bitSet;
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:24,代码来源:AsnFilter.java

示例7: deletePrimary

import org.apache.lucene.index.TermDocs; //导入方法依赖的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

示例8: deleteReference

import org.apache.lucene.index.TermDocs; //导入方法依赖的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

示例9: deleteContainerAndBelow

import org.apache.lucene.index.TermDocs; //导入方法依赖的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

示例10: getDocIdSet

import org.apache.lucene.index.TermDocs; //导入方法依赖的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

示例11: getNodeDocs

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
public synchronized TermDocs getNodeDocs() throws IOException
{
    if (nodes == null)
    {
        TermDocs nodeDocs = termDocs(new Term("ISNODE", "T"));
        nodes = new OpenBitSet();
        while (nodeDocs.next())
        {
            nodes.set(nodeDocs.doc());
        }
        nodeDocs.close();
    }
    return new TermDocSet(nodes);
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:15,代码来源:ReferenceCountingReadOnlyIndexReaderFactory.java

示例12: queryAcls

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
/**
 * Queries the ACL values indexed for a document.
 * @param uuid the document UUID
 * @return the ACL values (can be null)
 * @throws CatalogIndexException if an exception occurs
 */
@Override
public String[] queryAcls(String uuid)  throws CatalogIndexException {
  ArrayList<String> values = new ArrayList<String>();
  IndexSearcher searcher = null;
  TermDocs termDocs = null;
  try {
    uuid = Val.chkStr(uuid);
    if (uuid.length() > 0) {
      searcher = newSearcher();
      String[] aFields = new String[]{Storeables.FIELD_ACL};
      MapFieldSelector selector = new MapFieldSelector(aFields);
      searcher = newSearcher();
      IndexReader reader = searcher.getIndexReader();
      termDocs = reader.termDocs();
      termDocs.seek(new Term(Storeables.FIELD_UUID,uuid));
      if (termDocs.next()) {
        Document document = reader.document(termDocs.doc(),selector);
        Field[] fields = document.getFields(Storeables.FIELD_ACL);
        if ((fields != null) && (fields.length > 0)) {
          for (Field field: fields) {
            values.add(field.stringValue());
          }
        }
      } 
    }
  } catch (IOException e) {
    String sMsg = "Error accessing index:\n "+Val.chkStr(e.getMessage());
    throw new CatalogIndexException(sMsg,e);
  } finally {
    try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
    closeSearcher(searcher);
  }
  return values.toArray(new String[0]);
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:41,代码来源:LuceneIndexAdapter.java

示例13: queryModifiedDate

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
/**
 * Queries the system modified date associated with an indexed document.
 * @param uuid the document UUID
 * @return the update date (null if none was found)
 * @throws CatalogIndexException if an exception occurs
 */
@Override
public Timestamp queryModifiedDate(String uuid) throws CatalogIndexException {
  Timestamp tsUpdate = null;
  IndexSearcher searcher = null;
  TermDocs termDocs = null;
  try {
    uuid = Val.chkStr(uuid);
    if (uuid.length() > 0) {
      String[] aFields = new String[]{Storeables.FIELD_DATEMODIFIED};
      MapFieldSelector selector = new MapFieldSelector(aFields);
      searcher = newSearcher();
      IndexReader reader = searcher.getIndexReader();
      termDocs = reader.termDocs();
      termDocs.seek(new Term(Storeables.FIELD_UUID,uuid));
      if (termDocs.next()) {
        Document document = reader.document(termDocs.doc(),selector);
        String sUpdate = document.get(Storeables.FIELD_DATEMODIFIED);
        tsUpdate = new Timestamp(Long.valueOf(sUpdate));
      }
    }
  } catch (IOException e) {
    String sMsg = "Error accessing index:\n "+Val.chkStr(e.getMessage());
    throw new CatalogIndexException(sMsg,e);
  } finally {
    try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
    closeSearcher(searcher);
  }
  return tsUpdate;
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:36,代码来源:LuceneIndexAdapter.java

示例14: loadAssertionById

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
/**
 * Loads an assertion based upon the subject id of the active operation.
 * @param context the assertion operation context
 * @param mustExist <code>true</code> true if the assertion must exist
 * @return the assertion (null if not found)
 * @throws CorruptIndexException if the index is corrupt
 * @throws IOException if an I/O exception occurs
 * @throws AsnInvalidOperationException if mustExist and the assertion was not found
 */
public Assertion loadAssertionById(AsnContext context, boolean mustExist) 
  throws CorruptIndexException, IOException, AsnInvalidOperationException {
  TermDocs termDocs = null;
  IndexReader reader = null;
  AsnOperation operation = context.getOperation();
  try {
    String assertionId = Val.chkStr(operation.getSubject().getValuePart());
    if (assertionId.length() > 0) {
      reader = this.makeIndexReader();
      termDocs = reader.termDocs();
      termDocs.seek(new Term(AsnConstants.FIELD_SYS_ASSERTIONID,assertionId));
      if (termDocs.next()) {
        Document document = reader.document(termDocs.doc());
        Assertion assertion = operation.getAssertionSet().newAssertion(context,false);
        assertion.load(document);
        return assertion;
      }
    }
  } finally {
    try {if (termDocs != null) termDocs.close();} catch (Exception ef) {}
    this.closeReader(reader);
  }
  if (mustExist) {
    String msg = "This assertion id was not found - "+operation.getSubject().getURN();
    throw new AsnInvalidOperationException(msg);
  }
  return null;
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:38,代码来源:AsnIndexAdapter.java

示例15: getDocIdSet

import org.apache.lucene.index.TermDocs; //导入方法依赖的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.TermDocs.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。