IK分词器提供了两个算法:ik_smart 和 ik_max_word
GET http://localhost:9200/_analyze?analyzer=ik_smart&pretty=true&text=我是程序员 { "tokens": [ { "token": "我", "start_offset": 0, "end_offset": 1, "type": "CN_CHAR", "position": 0 }, { "token": "是", "start_offset": 1, "end_offset": 2, "type": "CN_CHAR", "position": 1 }, { "token": "程序员", "start_offset": 2, "end_offset": 5, "type": "CN_WORD", "position": 2 } ] }
GET http://localhost:9200/_analyze?analyzer=ik_max_word&pretty=true&text=我是程序员 { "tokens": [ { "token": "我", "start_offset": 0, "end_offset": 1, "type": "CN_CHAR", "position": 0 }, { "token": "是", "start_offset": 1, "end_offset": 2, "type": "CN_CHAR", "position": 1 }, { "token": "程序员", "start_offset": 2, "end_offset": 5, "type": "CN_WORD", "position": 2 }, { "token": "程序", "start_offset": 2, "end_offset": 4, "type": "CN_WORD", "position": 3 }, { "token": "员", "start_offset": 4, "end_offset": 5, "type": "CN_CHAR", "position": 4 } ] }
原文:https://www.cnblogs.com/wange/p/12637757.html