Lucene.NET Delete.Documents BooleanQuery 未按预期工作
Lucene.NET Delete.Documents not working as expected for BooleanQuery
当我尝试使用 Occur.Should 通过布尔查询删除文档时,没有任何内容被删除
var query = new BooleanQuery();
query.Add(new TermQuery(new Term("Field", "A")), Occur.Should);
query.Add(new TermQuery(new Term("Field", "B")), Occur.Should);
writer.DeleteDocuments(query);
query.Clauses.Clear();
writer.Commit();
我预计“字段”值为“A”或“B”的文档将从索引中删除,但是当我从索引中获取文档时,那里仍然有“A”和“B”,我是否使用了方法不对?
事实证明,我不应该在提交前调用 Clauses.Clear()。该过程将清除所有布尔子句。删除clear部分,一切正常
var query = new BooleanQuery();
query.Add(new TermQuery(new Term("Field", "A")), Occur.Should);
query.Add(new TermQuery(new Term("Field", "B")), Occur.Should);
writer.DeleteDocuments(query);
writer.Commit();
当我尝试使用 Occur.Should 通过布尔查询删除文档时,没有任何内容被删除
var query = new BooleanQuery();
query.Add(new TermQuery(new Term("Field", "A")), Occur.Should);
query.Add(new TermQuery(new Term("Field", "B")), Occur.Should);
writer.DeleteDocuments(query);
query.Clauses.Clear();
writer.Commit();
我预计“字段”值为“A”或“B”的文档将从索引中删除,但是当我从索引中获取文档时,那里仍然有“A”和“B”,我是否使用了方法不对?
事实证明,我不应该在提交前调用 Clauses.Clear()。该过程将清除所有布尔子句。删除clear部分,一切正常
var query = new BooleanQuery();
query.Add(new TermQuery(new Term("Field", "A")), Occur.Should);
query.Add(new TermQuery(new Term("Field", "B")), Occur.Should);
writer.DeleteDocuments(query);
writer.Commit();