1. 查看標准分析器的分詞結果
http://127.0.0.1:9200/_analyze?analyzer=standard&text=標准分析器
都分成了單個漢字,不好用
2.第三方IKAnalyzer分析器
2.1 ES集成IK分析器
步驟一:將IK分析器壓縮包解壓
步驟二:將解壓后的文件夾復制到ES解壓目錄的plugins
步驟三: 重啟ES
注意:文件路徑不要帶空格
2.2 使用IK分析器進行分析
ik_smart 最小分析
http://127.0.0.1:9200/_analyze?analyzer=ik_smart&text=第三方IKAnalyzer分析器
ik_max_word 最細分析
http://127.0.0.1:9200/_analyze?analyzer=ik_max_word&text=第三方IKAnalyzer分析器
2.3 用ik分析器替換標准分析器,創建Type時,指定ik
{ "mappings":{ "hello":{ "properties":{ "id":{ "type":"long", "store":true, "index":"not_analyzed" }, "title":{ "type":"text", "store":true, "index":"analyzed", "analyzer":"ik_max_word" }, "cpontent":{ "type":"text", "store":true, "index":"analyzed", "analyzer":"ik_max_word" } } } } }
存倆條信息,搜索服務器索引