所有不说明elastic 版本的博客都是耍流氓
https://github.com/medcl/elasticsearch-analysis-pinyin/releases (拼音分词器)
https://github.com/medcl/elasticsearch-analysis-ik ik分词器
将分词器解压出来后,得到三个文件
1.在es的plugins目录下新建一个pinyin的目录
mkdir pingyin
2.将这三个文件放到pinyin的目录下
DELETE /index_name/
{
}
PUT /index_name/
{
"index": {
"analysis": {
"analyzer": {
"ik_pinyin_analyzer": {
"type": "custom",
"tokenizer": "ik_max_word",
"filter": ["my_pinyin", "word_delimiter"]
}
},
"filter": {
"my_pinyin": {
"type": "pinyin",
"first_letter": "prefix",
"padding_char": " "
}
}
}
}
}
设置每个属性涉及到的配置
PUT /index_name/app/_mapping
{
"app": {
"properties": {
"ProductCName": {
"type": "keyword",
"fields": {
"pinyin": {
"type": "text",
"store": false,
"term_vector": "with_positions_offsets",
"analyzer": "ik_pinyin_analyzer",
"boost": 10
}
}
},
"ProductEName":{
"type":"text",
"analyzer": "ik_max_word"
},
"Description":{
"type":"text",
"analyzer": "ik_max_word"
}
}
}
}
DELETEPUT /index_name/app/1
{
"ProductCName":"口红世家",
"ProductEName":"Red History",
"Description":"口红真是很棒的东西呢"
}
POST /index_name/_analyze?pretty
{
"analyzer": "pinyin",
"text":"王者荣耀"
}
本站主要用于日常笔记的记录和生活日志。本站不保证所有内容信息可靠!(大多数文章属于搬运!)如有版权问题,请联系我立即删除:“abcdsjx@126.com”。
QQ: 1164453243
邮箱: abcdsjx@126.com