你可以的,加油

同义词 有中英文混合的情况下,不生效

Elasticsearch | 作者 wengxuejie | 发布于2018年10月16日 | 阅读数:2754

配置了同义词,通过GET testces/_analyze
{
"analyzer": "by_smart",
"text":"就红"
}
也能生效, 但是同义词库里有中英文的情况,就不能生效,maping配置如下:
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"by_smart": {
"type": "custom",
"tokenizer": "ik_smart",
"filter": [
"by_tfr",
"by_sfr"
],
"char_filter": [
"by_cfr"
]
},
"by_max_word": {
"type": "custom",
"tokenizer": "ik_max_word",
"filter": [
"by_tfr",
"by_sfr",
"stemmer",
"snowball"
],
"char_filter": [
"by_cfr"
]
}
},
"filter": {
"by_tfr": {
"type": "stop",
"stopwords": [
" "
]
},
"by_sfr": {
"type": "synonym",
"synonyms_path": "analysis/synonyms.txt"
}
},
"char_filter": {
"by_cfr": {
"type": "mapping",
"mappings": [
"| => |"
]
}
}
}
},
"mappings": {
"doc": {
"include_in_all": false,
"dynamic": true,
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "text",
"analyzer": "by_smart",
"search_analyzer": "by_smart"
}
}
}
}
同义词库:
Armani,阿玛尼 => Armani
眼镜,眼睛 => 眼镜
GIVENCHY,纪梵希 => GIVENCHY
戒指,截止 => 戒指
就红=> 酒红
已邀请:

rochy - rochy_he

赞同来自:

先使用 analyze API 测试一下分词器有没有生效,有可能是因为同义词词典的路径不正确造成的,你可以设置为绝对路径试一下

wengxuejie

赞同来自:

已经解决,同义词是生效了,但是查不出数据,后来发现Armani,阿玛尼 => Armani  右边大写不行,换成小写就查出来了,具体原因,还的继续排查

要回复问题请先登录注册