配置了同义词,通过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
戒指,截止 => 戒指
就红=> 酒红
{
"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
戒指,截止 => 戒指
就红=> 酒红
2 个回复
rochy - rochy_he
赞同来自:
wengxuejie
赞同来自: