gpt4 book ai didi

elasticsearch - elasticsearch:尽管使用了法语分析器,但是带有重音的搜索问题

转载 作者:行者123 更新时间:2023-12-02 22:58:38 25 4
gpt4 key购买 nike

当我在没有重音符号的情况下进行搜索时,尽管我在映射中设置了法语分析器,但没有与具有重音符号的相同单词匹配

这是我的映射:

PUT /test12h31
{
"mappings": {
"proj": {
"properties": {
"movieTitle": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"analyzer": "french"
}
}
}
}
}

我输入以下数据:
 PUT /test12h31/proj/_search
{
"movieTitle":"Le Retour Du Héros"
}

当我执行此搜索时,我没有任何结果:
POST /test12h31/proj/_search
{
"query": {
"match": {
"movieTitle": "hero"
}
}
}

当我在搜索请求中用“héro”替换“hero”时,我得到了结果。

您能帮我理解会发生什么以及如何忽略重音吗?

最佳答案

french分析器不会处理重音符号,因为您需要包括asciifolding token 过滤器。

我建议您像这样修改索引设置和映射,以便重新定义french分析器以包括asciifolding token 过滤器:

PUT /test12h31
{
"settings": {
"analysis": {
"filter": {
"french_elision": {
"type": "elision",
"articles_case": true,
"articles": [
"l", "m", "t", "qu", "n", "s",
"j", "d", "c", "jusqu", "quoiqu",
"lorsqu", "puisqu"
]
},
"french_stop": {
"type": "stop",
"stopwords": "_french_"
},
"french_stemmer": {
"type": "stemmer",
"language": "light_french"
}
},
"analyzer": {
"french": {
"tokenizer": "standard",
"filter": [
"french_elision",
"lowercase",
"asciifolding",
"french_stop",
"french_stemmer"
]
}
}
}
},
"mappings": {
"proj": {
"properties": {
"movieTitle": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"analyzer": "french"
}
}
}
}
}
}

然后,您将获得搜索结果。

关于elasticsearch - elasticsearch:尽管使用了法语分析器,但是带有重音的搜索问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42226496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com