我使用es 7.8.0版本,搜索的词是 sankio红豆蛋黄酥 搜索的词使用的是ik_smart分词器
es存储使用ik_max_word分词器
但是搜索sankio红豆蛋黄酥 无法匹配到 蛋黄酥 (红豆) 这个商品
,但是我用红豆蛋黄酥来搜索就是可以匹配到的 我用分词器查看结果:
es存储使用ik_max_word分词器
但是搜索sankio红豆蛋黄酥 无法匹配到 蛋黄酥 (红豆) 这个商品
,但是我用红豆蛋黄酥来搜索就是可以匹配到的 我用分词器查看结果:
{
"analyzer":"ik_smart_ts_synonym",
"text":"sankio红豆蛋黄酥"
}
{
"tokens": [
{
"token": "sankio",
"start_offset": 0,
"end_offset": 6,
"type": "ENGLISH",
"position": 0
},
{
"token": "红豆",
"start_offset": 6,
"end_offset": 8,
"type": "CN_WORD",
"position": 1
},
{
"token": "蛋黄酥",
"start_offset": 8,
"end_offset": 11,
"type": "CN_WORD",
"position": 2
}
]
}
很明显是有蛋黄酥这个词元的,我在把商品的名字 蛋黄酥(红豆) ik_max_word分词结果贴上:
{
"tokens": [
{
"token": "蛋黄酥",
"start_offset": 0,
"end_offset": 3,
"type": "CN_WORD",
"position": 0
},
{
"token": "danhuangsu",
"start_offset": 0,
"end_offset": 3,
"type": "CN_WORD",
"position": 0
},
{
"token": "蛋黄",
"start_offset": 0,
"end_offset": 2,
"type": "CN_WORD",
"position": 1
},
{
"token": "danhuang",
"start_offset": 0,
"end_offset": 2,
"type": "CN_WORD",
"position": 1
},
{
"token": "酥",
"start_offset": 2,
"end_offset": 3,
"type": "CN_CHAR",
"position": 2
},
{
"token": "su",
"start_offset": 2,
"end_offset": 3,
"type": "CN_CHAR",
"position": 2
},
{
"token": "红豆",
"start_offset": 5,
"end_offset": 7,
"type": "CN_WORD",
"position": 3
},
{
"token": "hongdou",
"start_offset": 5,
"end_offset": 7,
"type": "CN_WORD",
"position": 3
}
]
}
也是包含蛋黄酥的,那么搜索的时候为啥匹配不到 我的搜索语句是:
{
"query": {
"bool": {
"must": {
"multi_match": {
"query": "sankio红豆蛋黄酥",
"fields": [
"title",
"title_en",
"keywords"
],
"type": "best_fields",
"operator": "OR",
"slop": 0,
"prefix_length": 0,
"max_expansions": 50,
"lenient": false,
"zero_terms_query": "NONE",
"boost": 1,
"minimum_should_match": "70%"
}
},
"should": [
{
"match_phrase": {
"title": {
"query": "sankio红豆蛋黄酥",
"boost": 1.5,
"slop": 0
}
}
},
{
"match_phrase": {
"keywords": {
"query": "sankio红豆蛋黄酥",
"boost": 1.5,
"slop": 0
}
}
}
]
}
},
"from": 0,
"size": 300
}
1 个回复
CurryQin
赞同来自: