开发者

Advice on architecture using Lucene?

开发者 https://www.devze.com 2023-04-12 09:35 出处:网络
I just want to know if I am on the right track with how I should architect 开发者_如何学编程my Lucene context in my application:

I just want to know if I am on the right track with how I should architect 开发者_如何学编程my Lucene context in my application:

  1. Create a singleton class that will create an instance of the writer.
  2. Construct a reader each time the index needs to be read.
  3. Check the reader.IsCurrent() to determine if there are updates. 3a. If there are updates get the reader from the IndexWriter to use NRT.
  4. Commit any changes with regards to some threshold and reset the reader.

Let me know if I am on the right track. There is so much information about how to read and write, but not enough about using NRT and when to make commits properly.


You are mostly on the right path, but in fact, you can share a single instance of your reader/searcher in all the application without constructing it.

Try to have an index reader/writer factory if you have multiple indexes to manage them and if you can afford it, try to keep in the same application the reader and the writer, so you can benefit of the NRT feature of Lucene.NET.

Also, check this wiki for NRT advices:

http://wiki.apache.org/lucene-java/NearRealtimeSearch


I have been using almost the same exact architecture for awhile now, and I have found it to work fine. Instead of getting the reader from IndexWriter in step 3a, try using IndexReader.Reopen(). And in step 4, you can simply call Reopen() whenever IsCurrent() is false.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号