简体   繁体   English

Lucene.net和NHibernate搜索并发问题

[英]Lucene.net & NHibernate search concurrency issues

I have a web application which uses Lucene.Net and NHibernate.Search as a full-text search engine. 我有一个使用Lucene.Net和NHibernate.Search作为全文本搜索引擎的Web应用程序。 NHibernate.Search is setted up such that whenever a change is done in the database, it is propagated to the Lucene index. 设置NHibernate.Search,以便每当数据库中进行更改时,该更改就会传播到Lucene索引。

The web application is running using 4 worker processes. 该Web应用程序正在使用4个工作进程运行。 First of all, is this an issue? 首先,这是一个问题吗? I am noticing that the Lucene index is not 100% in sync with the database. 我注意到Lucene索引不是与数据库同步100%。 Some changes to the database are not appearing in the Lucene index. 对数据库的某些更改未出现在Lucene索引中。 However, when I manually try to re-index the data, this works fine. 但是,当我手动尝试为数据重新编制索引时,这可以正常工作。

Are there any concurrency implications with using Lucene.Net in a multi-process environment? 在多进程环境中使用Lucene.Net有任何并发​​影响吗?

This sounds like an issue with an open IndexWriter keeping locks on the index directory. 这听起来像一个打开的IndexWriter保持对索引目录的锁定的问题。 One worker process would lock the index for the other processes. 一个工作进程将锁定其他进程的索引。

Lucene.Net can be used in a multi-process environment as long as there's only one writer per index. 只要每个索引只有一个作者,Lucene.Net可以在多进程环境中使用。 Different directory implementations enforce this in different ways, usually involving a file named write.lock . 不同的目录实现以不同的方式实施此操作,通常涉及一个名为write.lock的文件。

A common solution is to have a separate search process which handles indexing and searching. 常见的解决方案是拥有一个单独的搜索过程来处理索引和搜索。

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

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