0

I created a task in scheduled task to update my lucene index. Everything is going well until I searched in my lucene and the task to update the index run at the same time.

My Code in Lucene is to delete the old index and create a new one, I know that it needs the former file in order to search, but when I put IndexWriter Property create to false, it works, but the index file folder seems to create more "files/index" and the index search list contains the two or three of the same indexed "term".

Is their a way to append it and exclude the previous indexed terms in the update? Because I'm having a hard time to understand the Update Method of Lucene.

Filburt
  • 17,626
  • 12
  • 64
  • 115
Gabriel Llorico
  • 1,783
  • 1
  • 13
  • 23
  • Hi, can you see this https://lucene.apache.org/core/2_9_4/fileformats.html it might help you a little in understanding lucene index files. and https://lucene.apache.org/core/3_6_1/api/core/org/apache/lucene/index/IndexWriter.html Sorry I'm not in touch with it right now. But it's how lucene behaves, it creates multiple index files. Lucene.NET and Lucene have mostly same functionality so I feel above links should help you a little http://blog.asteriosk.gr/2009/03/31/merging-multiple-lucene-indexes/ above code is in java but should be pretty similar for .net – Mandy Mar 02 '16 at 09:32
  • @Mandy thank you for your help – Gabriel Llorico Mar 04 '16 at 01:18
  • Did it help you? I'm glad if it did. You are most welcome. – Mandy Mar 06 '16 at 11:36
  • It's probably "wrong" to delete the index and rewrite. Consider the index in the same way as a SQL database. In order to add an "order", you wouldn't delete the DB and recreate it, right? Keep a singleton of your IndexWriter and do Update/Delete operations on it. Then use an IndexSearcher (created from the writer) to do your searches – AndyPook Mar 20 '16 at 17:06

0 Answers0