我有一个供应商信息的数据库:名称和地址(地址,城市,邮编和国家/地区)。我需要搜索这个数据库并返回一些供应商。在搜索框中,用户可以输入任何内容:供应商的名称,地址的一部分,城市,邮编,......如果我找不到任何结果,我需要实施谷歌,如“你的意思是“功能给用户一个建议。基于多个字段的Solr/Lucene拼写检查建议
我想过使用Solr/Lucene来做到这一点。我已经安装了Solr,使用CSV文件导出了我需要的信息,并基于此文件创建了索引。现在我可以使用solr.SpellCheckComponent从Solr字段获取建议。事情是我的建议是基于单一领域,需要它从地址,城市,邮编,国家和名称字段获取信息。
在Solr的配置文件,我有这样的事情:
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">textSpell</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">name</str>
<str name="spellcheckIndexDir">spellchecker</str>
</lst>
</searchComponent>
<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="spellcheck.onlyMorePopular">false</str>
<str name="spellcheck.extendedResults">false</str>
<str name="spellcheck.count>1</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
我可以运行类似的查询:
http://localhost:8983/solr/spell?q=some_company_name&spellcheck=true&spellcheck.collate=true&spellcheck.build=true
有谁知道如何改变我的配置文件,以具有多项建议字段?
谢谢!
谢谢!它为我工作! – nepomucenobr