【发布时间】:2012-09-27 07:36:51
【问题描述】:
可能重复:
Why Lucene doesn't support any type of update to an existing document
是否可以在文档被索引后更新存储的字段值(无需重新索引)?
【问题讨论】:
标签: apache lucene indexing field
可能重复:
Why Lucene doesn't support any type of update to an existing document
是否可以在文档被索引后更新存储的字段值(无需重新索引)?
【问题讨论】:
标签: apache lucene indexing field
简短回答:没有。
您需要删除并重新添加文档,它是存储字段和索引字段。 见IndexWriter.updateDocument() Javadoc:
“通过首先删除包含术语的文档然后添加新文档来更新文档。删除然后添加是原子的,正如读者在同一索引上看到的那样(刷新可能仅在添加之后发生)。 "
另一种选择是在 Lucene 之外存储任何需要更新的数据(比如在关系数据库中)。
有各种各样的work in progress 允许就地更新、存储或索引字段,但对于 Lucene V4 或更早版本没有具体内容。
【讨论】: