【发布时间】:2012-02-01 01:21:04
【问题描述】:
在尝试查找我们项目中的错误时,我发现自己对 Lucene 的索引 API 有几个问题,但没有答案: 第一个和下面的sn-p有关:
IndexWriter writer = //open an index for writings.
// ... do some heavy updates (inserts and deletes) to the index using 'writer'
IndexReader reader = writer.GetReader();
long[] idsArray = Field_Cache_Fields.DEFAULT.GetLongs(reader, "ID_Field");
//under the assumption that ALL indexed documents contain field with the name "ID_Field".
Lucene 的 API 是否承诺即使未提交索引,我所获得的阅读器也将始终获得更新?只是为了确保我的答案是明确的:每个已删除的文档都不会被读者看到,而每个添加的文档都会......
第二个问题与下一个sn-p有关:
IndexWriter writer = //open an index for writing, but dont change a thing - just commit meta data.
writer.Commit["Hello"] = "World";
writer.Commit();
是否承诺将元数据提交给索引,即使我打开它并没有对索引进行实际更改?
在这两个问题中,我很高兴知道 API 的含义,以及是否有人知道 Lucene .Net 2.9.2 特有的问题(任何错误?)
谢谢大家!
【问题讨论】:
-
我认为第一个问题在这个问题中得到了回答:stackoverflow.com/questions/5420566/…。除非您调用 Reopen(),否则基本上您不会在索引中看到任何更改。
-
是的,我想我读错了这个问题。如果您在调用 GetReader() 后对索引进行了更改,那么您将不会获得最新版本的索引。
标签: lucene lucene.net