简体   繁体   English

Lucene的IndexWriter澄清

[英]Lucene's IndexWriter clarifications

In attemp to find a bug in our project, I found myself with few questions about Lucene's indexing API with no answer: The first one is related to the following snippet: 试图在我们的项目中发现错误时,我发现自己对Lucene的索引API的疑问很少,但没有答案:第一个与以下代码段相关:

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".

Is it promised by Lucene's API that the reader that I get will ALWAYS get the updated, even though uncommited index? Lucene的API是否已承诺,即使索引未提交,我所获得的读者也将始终获得更新? Just to make sure my answer is clear: every deleted doc WONT be seen by the reader and every added doc WILL be.. 只是为了确保我的答案清楚:读者会看到每个删除的文档WONT,而每个添加的文档都会..

The second question is related to the next snippet: 第二个问题与下一个片段有关:

IndexWriter writer = //open an index for writing, but dont change a thing - just commit meta data.
writer.Commit["Hello"] = "World";
writer.Commit();

Is it promised that the metadata will be commited to the index, eventhough I opened it with no actual change to the index? 即使我在未对索引进行任何实际更改的情况下打开了元数据,是否保证将元数据提交给索引?

In both of the question I will be happy to know what was meant by the API, and also if some one knows about issues (any bugs?) specific with Lucene .Net 2.9.2 在这两个问题中,我都会很高兴知道API的含义,以及是否有人知道Lucene .Net 2.9.2特有的问题(任何错误?)。

thanks guys! 多谢你们!

First Question: yes 第一个问题:是的

From the doc: 从文档中:

Expert: returns a readonly reader, covering all committed as well as un-committed changes to the index. 专家:返回一个只读读取器,该读取器包含对索引的所有已落实和未落实的更改。 This provides "near real-time" searching, in that changes made during an IndexWriter session can be quickly made available for searching without closing the writer nor calling #commit . 这提供了“近实时”搜索,因为可以在不关闭编写器或调用#commit的情况下快速使在IndexWriter会话期间进行的更改可用于搜索。 Note that this is functionally equivalent to calling {#commit} and then using IndexReader#open to open a new reader. 请注意,这在功能上等同于调用{#commit},然后使用IndexReader#open打开新的阅读器。 But the turarnound time of this method should be faster since it avoids the potentially costly #commit . 但是此方法的处理时间应该更快,因为它避免了潜在的昂贵#commit。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM