gpt4 book ai didi

elasticsearch - 文本字段上的ElasticSearch Analyzer

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

这是我在elasticSearch上的 Realm :

"keywordName": {
"type": "text",
"analyzer": "custom_stop"
}

这是我的分析仪:
"custom_stop": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"my_stop",
"my_snow",
"asciifolding"
]
}

这是我的过滤器:
           "my_stop": {
"type": "stop",
"stopwords": "_french_"
},
"my_snow" : {
"type" : "snowball",
"language" : "French"
}

这是我的文档的索引(在我的唯一字段:keywordName中):

“canne peche”,“canne”,“canne a peche telescopique”,“iphone 8”,“iphone 8手机壳”,“iphone 8保护套”,“iphone 8充电器”,“iphone 8新”

当我搜索“canne”时,它给了我“canne”文档,这是我想要的:
GET ads/_search
{
"query": {
"match": {
"keywordName": {
"query": "canne",
"operator": "and"
}
}
},
"size": 1
}

当我搜索“canneàpêche”时,它也给我“canne peche”,也可以。与“CannesàPêche”->“canne a peche”-> OK相同。

这是棘手的部分:当我搜索“iphone 8”时,它给了我“iphone 8保护套”而不是“iphone 8”。如果更改大小,则设置为5(因为它返回包含“iphone 8”的5个结果)。我看到“iphone 8”在得分方面排名第四。首先是“iphone 8保护套”,然后是“iphone 8保护套”,然后是“iphone 8新”,最后是“iphone 8” ...

这是查询的结果:
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 5,
"max_score": 1.4009607,
"hits": [
{
"_index": "ads",
"_type": "keyword",
"_id": "iphone 8 cover",
"_score": 1.4009607,
"_source": {
"keywordName": "iphone 8 cover"
}
},
{
"_index": "ads",
"_type": "keyword",
"_id": "iphone 8 case",
"_score": 1.4009607,
"_source": {
"keywordName": "iphone 8 case"
}
},
{
"_index": "ads",
"_type": "keyword",
"_id": "iphone 8 new",
"_score": 0.70293105,
"_source": {
"keywordName": "iphone 8 new"
}
},
{
"_index": "ads",
"_type": "keyword",
"_id": "iphone 8",
"_score": 0.5804671,
"_source": {
"keywordName": "iphone 8"
}
},
{
"_index": "ads",
"_type": "keyword",
"_id": "iphone 8 charge",
"_score": 0.46705723,
"_source": {
"keywordName": "iphone 8 charge"
}
}
]
}
}

我该如何保持关键字“canne a peche”(重音,大写字母,复数形式)的灵活性,但又告诉他,如果存在完全匹配的内容(“iphone 8” =“iphone 8”),请给我确切的名称keywordName?

最佳答案

我建议是这样的:

    "keywordName": {
"type": "text",
"analyzer": "custom_stop",
"fields": {
"raw": {
"type": "keyword"
}
}
}

和查询:
{
"query": {
"bool": {
"should": [
{
"match": {
"keywordName": {
"query": "iphone 8",
"operator": "and"
}
}
},
{
"term": {
"keywordName.raw": {
"value": "iphone 8"
}
}
}
]
}
},
"size": 10
}

关于elasticsearch - 文本字段上的ElasticSearch Analyzer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43257656/

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