elasticsearch7.x中 ik+pinyin 搜索不到内容
Opened this issue · 1 comments
cosoc commented
索引设置
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"default": {
"tokenizer": "ik_max_word"
},
"pinyin_analyzer": {
"type": "custom",
"tokenizer": "my_pinyin",
"filter": [
"word_delimiter"
]
}
},
"tokenizer": {
"my_pinyin": {
"type": "pinyin",
"keep_first_letter": true,
"keep_separate_first_letter": false,
"keep_full_pinyin": true,
"keep_original": false,
"limit_first_letter_length": 16,
"lowercase": true
}
}
}
},
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "ik_max_word",
"fields": {
"pinyin": {
"type": "text",
"analyzer": "pinyin_analyzer",
"boost": 10
}
}
},
"content": {
"type": "text",
"analyzer": "ik_max_word"
},
"author": {
"type": "text",
"analyzer": "ik_max_word"
},
"keyword": {
"type": "text",
"analyzer": "ik_max_word"
}
}
}
}
创建文档
{
"title":"刘德华2018年演唱会将在北京举行",
"content":"刘德华2018年跨年演唱会将在北京市海淀剧院举行",
"author":"xioa"
}
查询文档
{
"query": {
"multi_match": {
"type":"most_fields",
"query":"刘德h",
"fields":["title", "title.pinyin"]
}
}
}
返回
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 0,
"relation": "eq"
},
"max_score": null,
"hits": []
}
}
彻底无语!新手被整蒙圈了
hs-llsong commented
我照着你这个示例,有搜到内容
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 2.8768206,
"hits": [
{
"_index": "test1",
"_type": "_doc",
"_id": "1",
"_score": 2.8768206,
"_source": {
"title": "刘德华2018年演唱会将在北京举行",
"content": "刘德华2018年跨年演唱会将在北京市海淀剧院举行",
"author": "xioa"
}
}
]
}
}