gpt4 book ai didi

sorting - ES按距离排序时出现错误

转载 作者:行者123 更新时间:2023-12-02 23:28:49 26 4
gpt4 key购买 nike

我正在尝试按距离对搜索结果进行排序。但是,当我尝试时,出现以下错误:

{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "sort option [location] not supported"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "roeselaredev",
"node": "2UYlfd7sTd6qlJWgdK2wzQ",
"reason": {
"type": "illegal_argument_exception",
"reason": "sort option [location] not supported"
}
}
]
},
"status": 400
}

我发送的查询如下所示:
GET _search
{
"query": {
"match_all": []
},
"sort": [

{
"geo_distance": {
"location": {
"lat": 50.9436034,
"long": 3.1242917
},
"order":"asc",
"unit":"km",
"distance_type":"plane"
}
},
{
"_score": {
"order":"desc"
}
}
]
}

据我所知,我按照信函中的说明进行操作。我没有得到格式错误的查询结果。我只是得到了不支持的按距离排序选项的结果。关于我在做什么错的任何想法吗?

最佳答案

查询dsl无效,OP几乎是正确的:)但缺少下划线。

当按距离排序时,它是_geo_distance而不是geo_distance

例:

GET _search
{
"query": {
"match_all": []
},
"sort": [

{
"_geo_distance": {
"location": {
"lat": 50.9436034,
"long": 3.1242917
},
"order":"asc",
"unit":"km",
"distance_type":"plane"
}
},
{
"_score": {
"order":"desc"
}
}
]
}

关于sorting - ES按距离排序时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39087892/

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