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 .
source share