1
在學嘗試找到在我們的項目中的錯誤,我發現自己有關Lucene的索引API沒有回答幾個問題: 第一個是涉及到下面的代碼片段:Lucene的IndexWriter類澄清
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承諾,我得到的讀者總是會得到更新的,即使是無限制的索引?只是爲了確保我的答案是明確的:每刪除文檔WONT由讀者和每一個加入的文檔被看作將..
第二個問題是有關下一個片段:
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
謝謝你們(任何錯誤?)!
我認爲第一個問題是在這個問題中回答:http://stackoverflow.com/questions/5420566/lucene-net-writing-reading-synchronization。除非你打電話給Reopen(),否則基本上你不會在索引中看到任何改變。 – goalie7960 2012-01-31 17:06:53
是的,我想我錯了。如果您在調用GetReader()後對索引進行了更改,那麼您將不會擁有最新版本的索引。 – goalie7960 2012-01-31 18:01:23