1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| 1. 将压缩包解压、重命名为ik_analyzer 2. 将 ik-analyzer-solr6.jar 复制到 solr lib目录下 cp ~/Downloads/ik_analyzer/ik-analyzer-solr6.jar ~/www/Java/solr/WEB-INF/lib 3. 将相关包放入solr classpath cp ~/Downloads/ik_analyzer/mydict.dic ~/Downloads/ik_analyzer/IKAnalyzer.cfg.xml ~/Downloads/ik_analyzer/ext_stopword.dic ~/www/Java/solr/WEB-INF/classes 若~/www/Java/solr/WEB-INF/classes文件夹不存在、需要新建 4. 配置schema <fieldType name="text_ik" class="solr.TextField"> <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/> </fieldType>
<field name="item_title" type="text_ik" indexed="true" stored="true"/> <field name="item_sell_point" type="text_ik" indexed="true" stored="true"/> <field name="item_price" type="plong" indexed="true" stored="true"/> <field name="item_image" type="string" indexed="false" stored="true" /> <field name="item_category_name" type="string" indexed="true" stored="true" />
<field name="item_keywords" type="text_ik" indexed="true" stored="false" multiValued="true"/> <copyField source="item_title" dest="item_keywords"/> <copyField source="item_sell_point" dest="item_keywords"/> <copyField source="item_category_name" dest="item_keywords"/>
其中:copyfiled是将item_title、item_sell_point、item_category_name都作为后边的item_keywords来搜索
5. 保存、重启tomcat、访问页面 http://localhost:8081/solr/index.html
|