gpt4 book ai didi

elasticsearch - Elasticsearch:在span_query中使用boost

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

我想在span_or查询中使用boost,但出现错误。

这是我的elasticsearch代码,错误返回

GET /addr/_search
{
"query":{
"span_near": {
"clauses" : [
{
"span_or": {
"clauses" : [
{
"span_term": {
"poi": {
"value": "long",
"boost" : 2.0
}
}
},
{
"span_term": {
"poi": {
"value": "mei"
}
}
}
]
}
},
{ "span_term" : { "poi" : "da" } }
],
"slop" : 1,
"in_order" : true
}
},
"sort": [{"freq": {"order": "desc"}}]
}
root_cause": [
{
"type": "parsing_exception",
"reason": "span_or [clauses] as a nested span clause can't have non-default boost value [2.0]",
"line": 15,
"col": 19
}
]

因此可以在span_or或span_near查询中使用boost吗?就像在bool查询中一样

最佳答案

boost参数仅用于外部范围查询...
如此处所述:
https://www.elastic.co/guide/en/elasticsearch/reference/current/span-queries.html

仅允许在外部跨度查询上设置提升。复合跨度查询(例如span_near)仅使用内部跨度查询的匹配跨度列表来查找自己的跨度,然后将其用于产生分数。分数永远不会在内部跨度查询中计算出来,这就是不允许提升的原因:它们只会影响分数的计算方式,而不会影响跨度。

GET /addr/_search
{
"query":{
"span_near": {
"boost" : 2.0 <-------------------- here //untested
"clauses" : [
{
"span_or": {
"boost" : 2.0 <-------------------- here //untested
"clauses" : [
{
"span_term": {
"poi": {
"value": "long",
"boost" : 2.0 <-------------- not allowed
}
}
},
{
"span_term": {
"poi": {
"value": "mei"
}
}
}
]
}
},
{ "span_term" : { "poi" : "da" } }
],
"slop" : 1,
"in_order" : true
}
},
"sort": [{"freq": {"order": "desc"}}]
}

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

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