gpt4 book ai didi

boost - 在_all上使用Wildcardsearch boost Elasticsearch

转载 作者:行者123 更新时间:2023-12-03 00:16:21 24 4
gpt4 key购买 nike

我正在尝试使用通配符和_all搜索文档。但是似乎不可能在_all上使用通配符获得提升的结果?

MappingRequest:

"theboostingclass": {
"properties": {
"Important": {
"boost": 2.0,
"type": "string"
},
"LessImportant": {
"type": "string"
},
"Garbage": {
"type": "string"
}
}
}
}

索引:
{
"index" :
{
"_index":"boosting",
"_type":"theboostingclass"
}
}
{
"Important":"bomb",
"LessImportant":"kruka",
"Garbage":"kalkon"
}
{
"index" :
{
"_index":"boosting",
"_type":"theboostingclass"
}
}
{
"Important":"kalkon",
"LessImportant":"bomb",
"Garbage":"bomber"
}
{
"index" :
{
"_index":"boosting",
"_type":"theboostingclass"
}
}
{
"Important":"kruka",
"LessImportant":"bomber",
"Garbage":"bomb"
}

询问
"query": {
"wildcard": {
"_all": {
"value": "*bomb*"
}
}
}

结果将以分数为1且看似随机的顺序还原所有匹配。我追求的不是什么。我希望“重要”字段的点击率更高。

如果我对所有3个字段都进行通配符搜索,那么评分似乎是正确的。但是我想在_all上使用它。有任何想法吗?

最佳答案

请在此处查看文档:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-term-rewrite.html。请注意,默认情况下使用恒定评分的原因是性能。

我相信您需要按以下方式修改查询:

"query": {
"wildcard": {
"_all": {
"value": "*bomb*",
"rewrite": "scoring_boolean"
}
}
}

关于boost - 在_all上使用Wildcardsearch boost Elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35869764/

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