Search is not sensitive when indexing with Lucene

When I re-index the database data of my application and search at the same time, the thread performing the search will sleep until it is re-indexed. I assume that indexing methods are thread safe to prevent data from changing when indexing. Is there a built-in way in Lucene that it only responds to a search (where the data does not change)? Or should I start thinking about something on my own? I am running my application on a Tomcat server.

Thanks, Tomer

+4
source share
1 answer

I assume that you are actually rebuilding the index (or reindexing everything from scratch, as opposed to reindexing individual documents). While the index is being rebuilt, you cannot execute queries against it because it is not in a consistent state.

The simplest solution that is often used is to rebuild the index in the background (while querying the old one), and then replace it with the new one.

If the problem you are experiencing is related to frequent server crashes, it might be worth considering another system approach similar to that implemented, for example, in Zoie β€” it records subsequent indexing requests, so it can recover from the last valid index snapshot .

+1
source

All Articles