1、一个最基本的高亮例子
创建index的mappings
PUT /blog_website { "mappings": { "blogs": { "properties": { "title": { "type": "text", "analyzer": "ik_max_word" }, "content": { "type": "text", "analyzer": "ik_max_word" } } } } }
|
看一下分词效果
GET /_analyze { "text":"我发表的第一篇博课", "analyzer":"ik_max_word" } 结果: { "tokens": [ { "token": "我", "start_offset": 0, "end_offset": 1, "type": "CN_CHAR", "position": 0 }, { "token": "发表", "start_offset": 1, "end_offset": 3, "type": "CN_WORD", "position": 1 }, { "token": "发", "start_offset": 1, "end_offset": 2, "type": "CN_WORD", "position": 2 }, { "token": "表", "start_offset": 2, "end_offset": 3, "type": "CN_WORD", "position": 3 }, { "token": "第一篇", "start_offset": 4, "end_offset": 7, "type": "CN_WORD", "position": 4 }, { "token": "第一", "start_offset": 4, "end_offset": 6, "type": "CN_WORD", "position": 5 }, { "token": "一篇", "start_offset": 5, "end_offset": 7, "type": "CN_WORD", "position": 6 }, { "token": "一", "start_offset": 5, "end_offset": 6, "type": "TYPE_CNUM", "position": 7 }, { "token": "篇", "start_offset": 6, "end_offset": 7, "type": "COUNT", "position": 8 }, { "token": "博", "start_offset": 7, "end_offset": 8, "type": "CN_CHAR", "position": 9 }, { "token": "课", "start_offset": 8, "end_offset": 9, "type": "CN_CHAR", "position": 10 } |