本文整理匯總了Java中org.apache.lucene.index.IndexReader.deleteDocument方法的典型用法代碼示例。如果您正苦於以下問題:Java IndexReader.deleteDocument方法的具體用法?Java IndexReader.deleteDocument怎麽用?Java IndexReader.deleteDocument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.lucene.index.IndexReader
的用法示例。
在下文中一共展示了IndexReader.deleteDocument方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}