tily-one  

#拼音分词器
GET _analyze
{
"text": "如家酒店",
"analyzer": "pinyin"
}

#ik分词器
GET _analyze
{
"text": "如家酒店",
"analyzer": "ik_smart"
}

DELETE test

PUT /test
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "ik_max_word",
"filter": "py"
}
},
"filter": {
"py": {
"type": "pinyin",
"keep_full_pinyin": false,
"keep_joined_full_pinyin": true,
"keep_original": true,
"limit_first_letter_length": 16,
"remove_duplicated_term": true,
"none_chinese_pinyin_tokenize": false
}
}
}
},
"mappings": {
"properties": {
"name":{
"type": "text",
"analyzer": "my_analyzer",
"search_analyzer": "ik_smart"
}
}
}
}

GET test/_analyze
{
"text": "如家酒店",
"analyzer": "my_analyzer"
}

POST /test/_doc/1
{
"id" :1,
"name" : "狮子"
}

POST /test/_doc/2
{
"id" :1,
"name" :"虱子"
}

GET test/_search
{
"query": {
"match": {
"name": "狮子"
}
}
}

 

 

posted on 2022-11-07 14:42  tily-one  阅读(70)  评论(0编辑  收藏  举报