简体   繁体   English

Lucene - 验证索引的完整性

[英]Lucene - Validate completeness of index

We are using Lucene 5.5.5 in order to allow full text search over our database content.我们使用 Lucene 5.5.5 以允许对我们的数据库内容进行全文搜索。 We build the index after a database migration and make use of the near-real-time indexmanager in order to keep the index up-to-date.我们在数据库迁移后构建索引,并使用近实时索引管理器来保持索引是最新的。 However, sometimes it may happen that the server is killed before the indexmanager could commit the index-entries that it still holds in memory.但是,有时可能会发生服务器在 indexmanager 提交它仍然保存在 memory 中的索引条目之前被杀死的情况。

In order to avoid having to always rebuild the index on server-startup, since it's quite slow, I was wondering whether the index could be checked for completion.为了避免总是在服务器启动时重建索引,因为它很慢,我想知道是否可以检查索引是否完成。 I know there's the CheckIndex -Utility, but as far as I understood it can only check whether an index is broken, but not if it's complete.我知道有CheckIndex -Utility,但据我了解,它只能检查索引是否损坏,但不能检查是否完整。

Another option could be an indexer that doesn't fully rebuild but completes an already existing index.另一种选择可能是不完全重建但完成现有索引的索引器。

What would be the best way to go about this? go 关于这个问题的最佳方法是什么? My goal is to waste as little time as possible on startup and have a complete index.我的目标是在启动时尽可能少地浪费时间,并拥有一个完整的索引。

An obvious solution would be to not use the near-real-time indexmanager anymore I guess, but for now, I'd like to not consider that option.我猜一个明显的解决方案是不再使用近实时索引管理器,但现在,我不想考虑这个选项。

Indeed, near-real-time indexmanager buffers the modifications in a memory and as far as i know currently it's not possible to verify the completeness of index flushing.事实上,近实时索引管理器缓冲 memory 中的修改,据我所知,目前无法验证索引刷新的完整性。

So the solutions could be:所以解决方案可能是:

  1. switch to directory-based indexmanager.切换到基于目录的索引管理器。 (drawback: worse performance comparing to near-real-time indexmanager ) (缺点:与近实时 indexmanager 相比性能更差)

  2. use healthcheck service that will check state of your app and update a flag isServerForciblyClosed in the db and if it's true then rebuild index on next startup.使用运行状况检查服务来检查您的应用程序的healthcheck并更新数据库中的isServerForciblyClosed标志,如果为true ,则在下次启动时重建索引。 This service should be turned off in case of planned shutdown.如果计划关闭,应关闭此服务。

  3. create your own CustomIndexManager implementation extending built-in classes or completly from scratch implementing Indexmanager interface创建您自己的CustomIndexManager实现扩展内置类或完全从头实现Indexmanager接口

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

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