<lst name="spellchecker">
<str name="name">suggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookupFactory</str>
<str name="field">name1</str>
<!-- the indexed field to derive suggestions from -->
<float name="threshold">0.005</float>
<str name="sourceLocation">suggest_dict.txt</str>
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler"
name="/suggest">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.count">10</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
词典文件示例:
凉席蚊帐 8.0
床品被套 8.0
毛毯/抱被/睡袋 8.0
居家餐具 8.0
清洁用品 8.0
口水巾\浴巾\毛巾 8.0
纸品 8.0
雅旦﹒戈乐 5.0
秋水伊人 Chiu Shui 5.0
相关定时生成代码:
}
Map<String, String> map = Maps.newHashMap();
map.put("q_state", "6");
ServiceResult<List<Product>> pageProduct = productService.pageProduct(map, null);
List<Product> products = pageProduct.getResult();
for (Product product : products) {
String replace = product.getName1().replace("【", "");
String replace2 = replace.replace("】", "");
sb.append(replace2).append("\n");
}
try {
FileUtils.writeStringToFile(new File("/opt/mmhlive.com/solr/solrhome/ejavashopcore/conf/suggest_dict.txt"), sb.toString());
} catch (IOException e) {
log.error("[ejavashop-admin][AdminJob][jobCreateSuggestText] 定时生成solr智能提示所需文档失败:"
+ e.toString());
e.printStackTrace();