简体   繁体   English

在使用 Lucene 建立索引期间搜索没有响应

[英]Searching is not responsive during indexing with Lucene

When I re-index the DB data of my application, and there is a search executed on the same time, the thread that runs the search is going to sleep until the re-indexing is done.当我重新索引我的应用程序的数据库数据并且同时执行搜索时,运行搜索的线程将进入休眠状态,直到重新索引完成。 I assume that the indexing methods are thread-safe in order to prevent change of the data while indexing.我假设索引方法是线程安全的,以防止在索引时更改数据。 Is there any built in way in Lucene to make it responsive only for search (where the data is not being changed)? Lucene 中是否有任何内置方式使其仅响应搜索(数据未更改)? Or should I start thinking about something on my own?还是我应该开始自己思考一些事情? I'm running my application on a Tomcat server.我在 Tomcat 服务器上运行我的应用程序。

Thanks, Tomer谢谢,托默

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 perform the queries against it, because it's not in consistent state.在重建索引时,您无法对其执行查询,因为它与 state 不一致。

The simplest solution that is often used is to rebuild the index in the background (while still performing the queries against the old one) and then replace it with the fresh one.经常使用的最简单的解决方案是在后台重建索引(同时仍然对旧索引执行查询),然后用新索引替换它。

If the problem you are facing is connected with frequent server crashes, it might be worthwhile to look at some more systematical approach like the one that is implemented for example in Zoie -- it records subsequent indexing requests, so it can recover from the last correct snapshot of the index.如果您面临的问题与频繁的服务器崩溃有关,则可能值得研究一些更系统的方法,例如在Zoie中实现的方法——它记录后续的索引请求,因此它可以从最后一次正确恢复索引快照。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM