欢迎投稿

今日深度:

Solr锁机制,

Solr锁机制,


Lucene索引,然后让solr能及时查询到lucene做的索引方案:

 

1、Lucene索引。(先删除锁)

while (IndexWriter.isLocked(directory) )

{

      IndexWriter.unlock(directory);

}

 

2、solr提交数据后有一个reopen索引操作,lucene虽然做了索引,但是solr并没有进行这个动作,所以要调用solr手动来实现。(这边无法调用删除锁的接口)

http://localhost:8081/solr/admin/cores?action=RELOAD&core=event

 

3、lucene调用indexWrite.close();包括解锁(删除write.lock)和释放。

 

 

 

 

1、 修改solrconfig.xml中的配置文件:

<unlockOnStartup>true</unlockOnStartup>

将solrcore启动时不设置锁。

 

<lockType>${solr.lock.type:simple} </lockType>

提供了四种索引锁机制,single,native,simple,Defaults,默认是native,如果是Lucene索引,想要solr来识别,则要改为simple。

 

 single = SingleInstanceLockFactory - suggested for a

                  read-only index or when thereis no possibility of

                 another process trying tomodify the index.

 native = NativeFSLockFactory - uses OS native file locking.

                  Do not use when multiple solrwebapps in the same

                  JVM are attempting to share asingle index.

 simple = SimpleFSLockFactory  -uses a plain file for locking

 

  Defaults: 'native' is default for Solr3.6 andlater, otherwise

                   'simple' is the default

 

然后lucene中一定要释放该锁,native的锁lucene释放不了。

 

 

www.htsjk.Com true http://www.htsjk.com/solr/39125.html NewsArticle Solr锁机制, Lucene索引,然后让solr能及时查询到lucene做的索引方案:   1、Lucene索引。(先删除锁) while (IndexWriter. isLocked (directory) ) {       IndexWriter. unlock (directory); }   2、solr提交数...
相关文章
    暂无相关文章
评论暂时关闭