本文介绍了Lucene:基于多个字段从索引中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从lucene搜索索引中删除文档。标准方法:
I need to perform deletion of the document from lucene search index. Standard approach :
indexReader.deleteDocuments(new Term("field_name", "field value"));
不会这样做:我需要根据多个字段执行删除。我需要这样的东西:
Won't do the trick: I need to perform the deletion based on multiple fields. I need something like this:
(pseudo code)
TermAggregator terms = new TermAggregator();
terms.add(new Term("field_name1", "field value 1"));
terms.add(new Term("field_name2", "field value 2"));
indexReader.deleteDocuments(terms.toTerm());
是否有任何构造?
推荐答案
IndexWriter
具有允许更强大删除的方法,例如。您可以使用要删除的术语的组合构建一个BooleanQuery,并使用它。
IndexWriter
has methods that allow more powerful deleting, such as IndexWriter.deleteDocuments(Query)
. You can build a BooleanQuery with the conjunction of terms you wish to delete, and use that.
这篇关于Lucene:基于多个字段从索引中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!