nep*_*obr 3 lucene solr spell-checking
我有一个包含供应商信息的数据库:名称和地址(地址,城市,邮编和国家/地区).我需要搜索这个数据库并返回一些供应商.在搜索框中,用户可以输入任何内容:供应商的名称,地址的一部分,城市,邮政编码......如果我找不到任何结果,我需要像谷歌一样实施"你的意思是"向用户提供建议的功能.
我想过使用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>
Run Code Online (Sandbox Code Playgroud)
我可以运行如下查询:
http://localhost:8983/solr/spell?q=some_company_name&spellcheck=true&spellcheck.collate=true&spellcheck.build=true
Run Code Online (Sandbox Code Playgroud)
有谁知道如何更改我的配置文件,以获得多个字段的建议?
谢谢!!!
您可以在schema.xml中使用copyfield.<copyField source="*" dest="contentSpell"/>将所有字段复制到contentSpell.
然后更改<str name="field">name</str>为<str name="field">contentSpell</str>en您将获得所有领域的建议.
为了将Solr拼写检查配置为使用来自多个字段的单词,您应该:
<field name="didYouMean" type="textSpell" indexed="true" multiValued="true"/>.<copyField source="field1" dest="didYouMean"/>
<copyField source="field2" dest="didYouMean"/>.<str name="field">didYouMean</str>.有关更多详细信息,请访问Solr spellcheck来自多个领域的化合物
| 归档时间: |
|
| 查看次数: |
4742 次 |
| 最近记录: |