Solr suggester in SolrCloud mode

我的梦境 提交于 2019-12-19 11:42:19

问题


I am running the solr in CloudSolr mode with three shards. The data is already indexed into solr. Now I have configured the solr suggester in solrconfig.xml. This is the configuration from solrconfig file. I am using solr 4.10 version.

<searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
        <str name="name">mysuggest</str>
        <str name="lookupImpl">FuzzyLookupFactory</str>
        <str name="storeDir">suggester_fuzzy_dir</str>
        <str name="dictionaryImpl">DocumentDictionaryFactory</str>
        <str name="field">businessName</str>
        <str name="payloadField">profileId</str>
        <str name="weightField">businessName</str>
        <str name="suggestAnalyzerFieldType">text_general</str>
        <str name="buildOnStartup">false</str>
    </lst>
</searchComponent>

<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
        <str name="suggest">true</str>
        <str name="suggest.count">10</str>
    </lst>
    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>

Here is the command I am using to fetch the result:

http://shard1:8900/solr/core/suggest?suggest=true&suggest.build=true&suggest.reload&suggest.dictionary=mysuggest&wt=json&indent=true&suggest.q=sale

This is the output of the command:

{
"responseHeader":{
"status":0,
"QTime":1490},
"command":"build",
"suggest":{}
}

Nothing is coming into suggest result. I have 10K records indexed into solr.

I am seeing the following into log file:

org.apache.solr.handler.component.SuggestComponent; http://shard1:8983/solr/core/ : null
org.apache.solr.handler.component.SuggestComponent; http://shard2:8900/solr/core/ : null
org.apache.solr.handler.component.SuggestComponent; http://shard3:7574/solr/core/ : null

I am not able understand what is missing here. Thanks.


回答1:


It was not working because solr was running in SolrCloud mode. There is two ways to perform suggestion in solrCloud mode:

  • Use the distrib=false parameter. This will fetch the data from only one shard which you are accessing in the command. You can add the following into Component definition itself.

    <bool name="distrib">false</bool> 
    
  • Use the shards and shards.qt parameter for searching all the shards. The shards parameter will contain comma separated list of all the shards which you want to include in the query. The shards.qt parameter will define the reat API you want to access.

shards.qt: Signals Solr that requests to shards should be sent to a request handler given by this parameter. Use shards.qt=/spell when making the request if your request handler is "/spell".

shards: shards=solr-shard1:8983/solr,solr-shard2:8983/solr Distributed Search

Please check Here for more details.



来源:https://stackoverflow.com/questions/32045700/solr-suggester-in-solrcloud-mode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!