gpt4 book ai didi

elasticsearch - 带过滤器的函数评分 elasticsearch

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

我想要一个函数,它获取所有结果,并且只在它们匹配过滤器时才对它们进行排序。
我试过这些查询,但没有结果。有人可以帮忙吗?

试用 1:

{
"query": {
"function_score": {
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"term": {
"category_boats": "motor_boat"
}
}
]
}
}
}
},
"functions": [

],
"score_mode": "first"
}
}
}

试用 2:
{
"query": {
"function_score": {
"query": {
"match_all": {}
},
"functions": [
{
"filter": {
"term": {
"boat_type": "offshore_yacht"
}
},
"weight": 1
},
{
"filter": {
"term": {
"year_built": "2016"
}
},
"weight": 1
},
{
"filter": {
"term": {
"manufacturer": "MasterCraft"
}
},
"weight": 2
}
],
"score_mode": "first"
}
}
}

在最后一个代码中,我收到一个错误:没有注册名为 [weight] 的函数。]
那么是否支持过滤器的重量?一些帮助?

最佳答案

支持 weight在被称为 boost_factor 之前在 elasticsearch 1.4 中添加

例子:

{
"query": {
"function_score": {
"query": {
"match_all": {}
},
"functions": [
{
"filter": {
"term": {
"boat_type": "offshore_yacht"
}
},
"boost_factor": 1
},
{
"filter": {
"term": {
"year_built": "2016"
}
},
"boost_factor": 1
},
{
"filter": {
"term": {
"manufacturer": "MasterCraft"
}
},
"boost_factor": 2
}
],
"score_mode": "first"
}
}
}

关于elasticsearch - 带过滤器的函数评分 elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35410258/

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