gpt4 book ai didi

java - Lucene updateDocument删除文档,但计数不断增加

转载 作者:行者123 更新时间:2023-12-02 07:30:53 25 4
gpt4 key购买 nike

我正在使用 updateDocument() 方法来更新 lucene 索引中的文档。这是我的做法。

writer.updateDocument(new Term(Constants.DOC_ID_FIELD, doc.get(Constants.DOC_ID_FIELD)), doc);

我与 Luke 检查我的索引数据,发现在第二次运行索引时,Luke 告知已删除文档 - 不可用。所以基本上,文档被标记为已删除,但它仍然驻留在索引中。

我不想保留这些标记为已删除的文档。我做错了吗?

另外,我的理解是,当我更新文档时,它会删除旧文档,然后添加新文档。是不是这样?

最佳答案

从邮件列表中得到答案。

IndexWriter.updateDocument() deletes and then adds. So your index will have deleted docs. Why do you care? They'll go away eventually as segments get merged.

If you really do care, see IndexWriter,forceMergeDeletes(). See also the javadoc for that: This is often a horribly costly operation; rarely is it warranted.

关于java - Lucene updateDocument删除文档,但计数不断增加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12933215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com