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


Java TermDocs.next方法代码示例

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


在下文中一共展示了TermDocs.next方法的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: indexGet

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
private String indexGet(final String key) throws IOException {
    final Term s = new Term(KEY_FIELD, key);
    synchronized (this.luceneWriter) {
        for (int attempt = 0;; ++attempt) {
            try {
                final TermDocs termDocs = this.luceneReader.termDocs(s);
                if (termDocs.next()) {
                    final Document doc = this.luceneReader.document(termDocs.doc());
                    return doc.get(VALUE_FIELD);
                }
                return null;
            } catch (final Throwable ex) {
                indexError(ex, attempt);
            }
        }
    }
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:18,代码来源:HadoopMultiFileStore.java

示例4: main

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
public static void main(String[] args) {
		String indexPath = args[0];
		String url = args[1];

		try {
			IndexReader reader = IndexReader.open(FSDirectory.open(new File(indexPath)), false);

			Term s = new Term(LuceneDataStore.LuceneTransaction.KEY_NAME, url);
			TermDocs termDocs = reader.termDocs(s);

			if (termDocs.next()) {
				Document document = reader.document(termDocs.doc());
//				Record r = LuceneDataStore.unserializeRecord(document.getBinaryValue(LuceneDataStore.LuceneTransaction.VALUE_NAME));
//				System.out.println(r.toString(null, true));
			}
			else {
				logger.info("URI {} not found", url);
			}

			reader.close();
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
	}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:25,代码来源:LuceneIndexReader.java

示例5: filter

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
public boolean filter(Term t) 
{
	int freq = 0;
	TermDocs tDocs;
	
	try {
	    tDocs = indexReader.termDocs(t);
	    while( tDocs.next() ){
	      freq += tDocs.freq();
	    }
	    if( freq < minFreq ){
	      return false;
	    }
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	
    return true;		
}
 
开发者ID:semanticvectors,项目名称:semanticvectors,代码行数:22,代码来源:TermFreqFilter.java

示例6: getLargestTxIdByCommitTime

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
private long getLargestTxIdByCommitTime(SolrIndexReader reader, Long lastTxCommitTimeBeforeHoles)
            throws IOException
{
    long txid = -1;
    if (lastTxCommitTimeBeforeHoles != -1)
    {
        TermDocs docs = reader.termDocs(new Term(QueryConstants.FIELD_TXCOMMITTIME, NumericEncoder
                    .encode(lastTxCommitTimeBeforeHoles)));
        while (docs.next())
        {
            Document doc = reader.document(docs.doc());
            Fieldable field = doc.getFieldable(QueryConstants.FIELD_TXID);
            if (field != null)
            {
                long currentTxId = Long.valueOf(field.stringValue());
                if (currentTxId > txid)
                {
                    txid = currentTxId;
                }
            }
        }
    }
    return txid;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:LegacySolrInformationServer.java

示例7: getLargestChangeSetIdByCommitTime

import org.apache.lucene.index.TermDocs; //导入方法依赖的package包/类
private long getLargestChangeSetIdByCommitTime(SolrIndexReader reader, Long lastChangeSetCommitTimeBeforeHoles)
            throws IOException
{
    long txid = -1;
    if (lastChangeSetCommitTimeBeforeHoles != -1)
    {
        TermDocs docs = reader.termDocs(new Term(QueryConstants.FIELD_ACLTXCOMMITTIME, NumericEncoder
                    .encode(lastChangeSetCommitTimeBeforeHoles)));
        while (docs.next())
        {
            Document doc = reader.document(docs.doc());
            Fieldable field = doc.getFieldable(QueryConstants.FIELD_ACLTXID);
            if (field != null)
            {
                long currentTxId = Long.valueOf(field.stringValue());
                if (currentTxId > txid)
                {
                    txid = currentTxId;
                }
            }
        }
    }
    return txid;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:LegacySolrInformationServer.java

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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