如何添加多个suggesters定义Solr搜索组件 [英] How to add multiple suggesters definition in solr search components

查看:295
本文介绍了如何添加多个suggesters定义Solr搜索组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Solr的5.1。我想配置根据 Apache Solr实现维基在Solr搜索组件多个suggester定义

我已经完全配置单suggester和它的作品完美,但每当我试图配置多个suggester它给了我下面的错误

 显示java.lang.NullPointerException
    在org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:190)
    在org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
    在org.apache.solr.core.SolrCore.execute(SolrCore.java:1984)
    在org.apache.solr.core.QuerySenderListener.newSearcher(QuerySenderListener.java:64)
    在org.apache.solr.core.SolrCore $ 5.call(SolrCore.java:1751)
    在java.util.concurrent.FutureTask.run(FutureTask.java:262)
    在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615)
    在java.lang.Thread.run(Thread.java:745)
org.apache.lucene.store.AlreadyClosedException:这个目录被关闭
    在org.apache.lucene.store.BaseDirectory.ensureOpen(BaseDirectory.java:50)
    在org.apache.lucene.store.FSDirectory.getDirectory(FSDirectory.java:244)
    在org.apache.lucene.store.NativeFSLockFactory.makeFSLock(NativeFSLockFactory.java:85)
    在org.apache.lucene.store.FSLockFactory.makeLock(FSLockFactory.java:39)
    在org.apache.lucene.store.BaseDirectory.makeLock(BaseDirectory.java:44)
    在org.apache.lucene.index.IndexWriter<&初始化GT;(IndexWriter.java:774)
    在org.apache.lucene.search.suggest.analyzing.AnalyzingInfixSuggester.build(AnalyzingInfixSuggester.java:296)
    在org.apache.lucene.search.su​​ggest.Lookup.build(Lookup.java:193)
    在org.apache.solr.spelling.suggest.SolrSuggester.build(SolrSuggester.java:163)
    在org.apache.solr.handler.component.SuggestComponent$SuggesterListener.buildSuggesterIndex(SuggestComponent.java:524)
    在org.apache.solr.handler.component.SuggestComponent$SuggesterListener.newSearcher(SuggestComponent.java:506)
    在org.apache.solr.core.SolrCore $ 5.call(SolrCore.java:1751)
    在java.util.concurrent.FutureTask.run(FutureTask.java:262)
    在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615)
    在java.lang.Thread.run(Thread.java:745)org.apache.solr.common.SolrException
    在org.apache.solr.core.SolrCore<&初始化GT;(SolrCore.java:885)
    在org.apache.solr.core.SolrCore<&初始化GT;(SolrCore.java:652)
    在org.apache.solr.core.CoreContainer.create(CoreContainer.java:518)
    在org.apache.solr.core.CoreContainer $ 1.call(CoreContainer.java:283)
    在org.apache.solr.core.CoreContainer $ 1.call(CoreContainer.java:277)
    在java.util.concurrent.FutureTask.run(FutureTask.java:262)
    在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615)
    在java.lang.Thread.run(Thread.java:745)
了java.lang.RuntimeException:产生的原因
    在org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory.create(AnalyzingInfixLookupFactory.java:138)
    在org.apache.solr.spelling.suggest.SolrSuggester.init(SolrSuggester.java:107)
    在org.apache.solr.handler.component.SuggestComponent.inform(SuggestComponent.java:119)
    在org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:620)
    在org.apache.solr.core.SolrCore<&初始化GT;(SolrCore.java:868)
    ... 8个

以下是我solrconfig.xml中

<的SearchComponent类=solr.SuggestComponentNAME =建议>
  < LST NAME =suggester>
    < STR名=名与GT;建议< / STR>
    < STR NAME =lookupImpl> org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory< / STR>
    < STR NAME =dictionaryImpl> org.apache.solr.spelling.suggest.DocumentDictionaryFactory< / STR>
    < STR NAME =suggestAnalyzerFieldType> suggestAnalyzer< / STR>
    < STR NAME =queryAnalyzerFieldType> tokenAnalyzer< / STR>
    < STR NAME =场> suggest_Name< / STR> <! - 索引字段从得到的建议 - >
    < STR NAME =buildOnCommit>真< / STR>
  < / LST>
  < LST NAME =suggester>
    < STR名=名与GT; suggest2< / STR>
    < STR NAME =lookupImpl> org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory< / STR>
    < STR NAME =dictionaryImpl> org.apache.solr.spelling.suggest.DocumentDictionaryFactory< / STR>
    < STR NAME =suggestAnalyzerFieldType> suggestAnalyzer< / STR>
    < STR NAME =queryAnalyzerFieldType> tokenAnalyzer< / STR>
    < STR NAME =场> suggest_Manu< / STR> <! - 索引字段从得到的建议 - >
    < STR NAME =buildOnCommit>真< / STR>
  < / LST>
< /&的SearchComponent GT;< requestHandler类=solr.SearchHandlerNAME =/提示>
  < LST NAME =默认>
    < STR NAME =拼写检查>真< / STR>
    < STR NAME =建议>真< / STR>
    < STR NAME =suggest.dictionary>建议< / STR>
    < STR NAME =suggest.dictionary> suggest2< / STR>
    < STR NAME =spellcheck.onlyMorePopular>真< / STR>
    < STR NAME =spellcheck.count> 5℃/ STR>
    < STR NAME =spellcheck.collat​​e>真< / STR>
  < / LST>
  < ARR NAME =组件>
    < STR>建议< / STR>
  < / ARR>
< / requestHandler>


解决方案

谢谢您的回答@Dhanesh小号Radhakrishnar,你是正确的,但后来我们实际上改变的是AnalyzingInfixLookupFactory到FuzzyLookupFactory其作品,但我们的目的已经失去了。无论如何,我已经找到了解决方案,事情是这样的,我们需要增加分析仪的indexPath第二suggester的实施。 :)

 <的SearchComponent类=solr.SuggestComponentNAME =建议>
  < LST NAME =suggester>
    < STR名=名与GT; mySuggester< / STR>
    < STR NAME =lookupImpl> AnalyzingInfixLookupFactory< / STR>
    < STR NAME =dictionaryImpl> DocumentDictionaryFactory< / STR>
    < STR NAME =场> suggest_Manu< / STR> <! - 索引字段从得到的建议 - >
    < STR NAME =weightField> productId_meter< / STR>
    < STR NAME =suggestAnalyzerFieldType> suggestAnalyzer< / STR>
    < STR NAME =buildOnCommit>真< / STR>  < / LST>
  < LST NAME =suggester>    < STR名=名与GT; mySuggester2< / STR>
    < STR NAME =lookupImpl> AnalyzingInfixLookupFactory< / STR>
    < STR NAME =dictionaryImpl> DocumentDictionaryFactory< / STR>
    < STR NAME =场> suggest_Name< / STR> <! - 索引字段从得到的建议 - >
    < STR NAME =weightEx pression> productId_meter< / STR>
    < STR NAME =suggestAnalyzerFieldType> suggestAnalyzer< / STR>
    < STR NAME =indexPath>路径的系统-DIR / newSuggester2< / STR>
    < STR NAME =buildOnCommit>真< / STR>  < / LST>< /&的SearchComponent GT;

I am using solr 5.1. I am trying to configure multiple suggester definition in Solr search component according to Apache solr wiki.

I have configured single suggester perfectly and it works perfect but whenever I try to configure multiple suggester it gives me following errors

java.lang.NullPointerException
    at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:190)
    at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
    at org.apache.solr.core.SolrCore.execute(SolrCore.java:1984)
    at org.apache.solr.core.QuerySenderListener.newSearcher(QuerySenderListener.java:64)
    at org.apache.solr.core.SolrCore$5.call(SolrCore.java:1751)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)


org.apache.lucene.store.AlreadyClosedException: this Directory is closed
    at org.apache.lucene.store.BaseDirectory.ensureOpen(BaseDirectory.java:50)
    at org.apache.lucene.store.FSDirectory.getDirectory(FSDirectory.java:244)
    at org.apache.lucene.store.NativeFSLockFactory.makeFSLock(NativeFSLockFactory.java:85)
    at org.apache.lucene.store.FSLockFactory.makeLock(FSLockFactory.java:39)
    at org.apache.lucene.store.BaseDirectory.makeLock(BaseDirectory.java:44)
    at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:774)
    at org.apache.lucene.search.suggest.analyzing.AnalyzingInfixSuggester.build(AnalyzingInfixSuggester.java:296)
    at org.apache.lucene.search.suggest.Lookup.build(Lookup.java:193)
    at org.apache.solr.spelling.suggest.SolrSuggester.build(SolrSuggester.java:163)
    at org.apache.solr.handler.component.SuggestComponent$SuggesterListener.buildSuggesterIndex(SuggestComponent.java:524)
    at org.apache.solr.handler.component.SuggestComponent$SuggesterListener.newSearcher(SuggestComponent.java:506)
    at org.apache.solr.core.SolrCore$5.call(SolrCore.java:1751)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

org.apache.solr.common.SolrException
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:885)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:652)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:518)
    at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:283)
    at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:277)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException
    at org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory.create(AnalyzingInfixLookupFactory.java:138)
    at org.apache.solr.spelling.suggest.SolrSuggester.init(SolrSuggester.java:107)
    at org.apache.solr.handler.component.SuggestComponent.inform(SuggestComponent.java:119)
    at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:620)
    at org.apache.solr.core.SolrCore.<init>(SolrCore.java:868)
    ... 8 more

Following is my solrconfig.xml

<searchComponent class="solr.SuggestComponent" name="suggest">
  <lst name="suggester">
    <str name="name">suggest</str>
    <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory</str>
    <str name="dictionaryImpl">org.apache.solr.spelling.suggest.DocumentDictionaryFactory</str>
    <str name="suggestAnalyzerFieldType">suggestAnalyzer</str>
    <str name="queryAnalyzerFieldType">tokenAnalyzer</str>
    <str name="field">suggest_Name</str>  <!-- the indexed field to derive suggestions from -->
    <str name="buildOnCommit">true</str>
  </lst>
  <lst name="suggester">
    <str name="name">suggest2</str>
    <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory</str>
    <str name="dictionaryImpl">org.apache.solr.spelling.suggest.DocumentDictionaryFactory</str>
    <str name="suggestAnalyzerFieldType">suggestAnalyzer</str>
    <str name="queryAnalyzerFieldType">tokenAnalyzer</str>
    <str name="field">suggest_Manu</str>  <!-- the indexed field to derive suggestions from -->
    <str name="buildOnCommit">true</str>
  </lst>
</searchComponent>

<requestHandler class="solr.SearchHandler" name="/suggest">
  <lst name="defaults">
    <str name="spellcheck">true</str>
    <str name="suggest">true</str>
    <str name="suggest.dictionary">suggest</str>
    <str name="suggest.dictionary">suggest2</str>
    <str name="spellcheck.onlyMorePopular">true</str>
    <str name="spellcheck.count">5</str>
    <str name="spellcheck.collate">true</str>
  </lst>
  <arr name="components">
    <str>suggest</str>
  </arr>
</requestHandler>

解决方案

Thanks for your answer @Dhanesh S Radhakrishnar, You are right but then we are actually changing the AnalyzingInfixLookupFactory to FuzzyLookupFactory which works but our purpose has been lost. Anyhow i have found the solution and the thing is that, we need to add the indexPath of analyzer in the implementation of second suggester. :)

<searchComponent class="solr.SuggestComponent" name="suggest">
  <lst name="suggester">
    <str name="name">mySuggester</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">suggest_Manu</str>  <!-- the indexed field to derive suggestions from -->
    <str name="weightField">productId_meter</str>
    <str name="suggestAnalyzerFieldType">suggestAnalyzer</str>
    <str name="buildOnCommit">true</str>

  </lst>


  <lst name="suggester">

    <str name="name">mySuggester2</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">suggest_Name</str>  <!-- the indexed field to derive suggestions from -->
    <str name="weightExpression">productId_meter</str>
    <str name="suggestAnalyzerFieldType">suggestAnalyzer</str>
    <str name="indexPath">path-of-system-dir/newSuggester2</str>
    <str name="buildOnCommit">true</str>

  </lst>

</searchComponent>

这篇关于如何添加多个suggesters定义Solr搜索组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆