首页 > 其他分享 >ES拼音搜索分词器练习

ES拼音搜索分词器练习

时间:2022-11-07 14:58:44浏览次数:72  
标签:拼音 GET pinyin analyzer ik 分词器 text test ES

#拼音分词器
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": "狮子"
}
}
}

 

 

标签:拼音,GET,pinyin,analyzer,ik,分词器,text,test,ES
From: https://www.cnblogs.com/tily-one/p/16865915.html

相关文章