You*_*bit 1 lucene solr solr4j
我在CloudSolr模式下使用三个分片运行solr.数据已经索引到solr中.现在我在solrconfig.xml中配置了solr建议器.这是solrconfig文件的配置.我使用的是solr 4.10版本.
<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>
Run Code Online (Sandbox Code Playgroud)
这是我用来获取结果的命令:
http://shard1:8900/solr/core/suggest?suggest=true&suggest.build=true&suggest.reload&suggest.dictionary=mysuggest&wt=json&indent=true&suggest.q=sale
Run Code Online (Sandbox Code Playgroud)
这是命令的输出:
{
"responseHeader":{
"status":0,
"QTime":1490},
"command":"build",
"suggest":{}
}
Run Code Online (Sandbox Code Playgroud)
什么都没有提出结果.我有索引到索引的10K记录.
我在日志文件中看到以下内容:
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
Run Code Online (Sandbox Code Playgroud)
我无法理解这里缺少的东西.谢谢.
它没有工作,因为solr在SolrCloud模式下运行.在solrCloud模式下有两种方法可以执行建议:
使用distrib = false参数.这将仅从您在命令中访问的一个分片中获取数据.您可以将以下内容添加到组件定义本身.
<bool name="distrib">false</bool>
Run Code Online (Sandbox Code Playgroud)使用shards和shards.qt参数搜索所有分片.shards参数将包含要包含在查询中的所有分片的逗号分隔列表.shards.qt参数将定义您要访问的reat API.
shards.qt: 请求分片的信号Solr应发送到此参数给出的请求处理程序.如果您的请求处理程序是"/ spell",请在发出请求时使用shards.qt =/spell.
分片:分片= solr-shard1:8983/solr,solr-shard2:8983/solr 分布式搜索
请查看此处了解更多详情.