Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lucene real-time indexing?

What is the best way to achieve Lucene real-time indexing?

like image 937
Kip Avatar asked Jun 18 '10 06:06

Kip


2 Answers

Lucene has a feature called near-real-time search to address exactly this need.

It requires that your IndexReader is in the same JVM as your IndexWriter.

You make changes with the IndexWriter, and then open a reader directly from the writer using IndexReader.open(writer), or on older Lucene releases writer.getReader(). This call will normally be very fast (in proportion to how many changes you've made since last opening a reader) as it bypasses the costly commit normally required for opening a reader. It's able to search the un-committed changes in the writer.

This reader still searches a point-in-time snapshot from the writer, ie all changes as of when you opened it.

like image 75
Michael McCandless Avatar answered Nov 28 '22 02:11

Michael McCandless


Obtain an index reader from the index writer.

Update: Looks like the current method is to open a directory reader using an index writer object.

like image 23
Adrian Conlon Avatar answered Nov 28 '22 02:11

Adrian Conlon