gpt4 book ai didi

sorting - Elasticsearch _geo_distance排序错误

转载 作者:行者123 更新时间:2023-12-03 00:26:13 27 4
gpt4 key购买 nike

问候过花,

为什么我使用官方的nodejs客户端通过Elasticsearch(1.2.2)收到此错误?

Parse Failure [No mapping found for [[object Object]] in order to sort on]]
"sort":[{"_score":{}},{"[object Object]":{}}]

这是我的查询(JSON格式):
{
"index":"myidx",
"type":"mytype",
"body":{
"query":{
"filtered":{
"filter":{
"and":[
{"term":{"to":"WORLD"}},
{"or":[
{"term":{"invisible":false}},
{"term":{"user":"@geeko"}}
]},
{"term":{"blocked":false}}
]
},
"query":{"terms":{"text":["world"]}}
}
}
},
"sort":[
"_score",
{"_geo_distance":{"mytype.location":"0.0,0.0"}}
],
"from":0,
"size":20
}

顺便说一句,我所有的映射都已定义(特别是mytype.location是geo_point),并且如果删除_geo_distance排序,此查询将起作用。

亲切的问候

更新(映射和示例):
{
"template": "myidx",
"mytype": {
"dynamic": "strict",
"properties": {
"id": {"type": "long"},
"timestamp": {
"type": "date",
"format": "date_time"
},
"location": {"type": "geo_point"},
"user": {
"type": "string",
"index": "not_analyzed"
},
"text": {
"type": "string",
"analyzer": "simple"
},
"to": {
"type": "string",
"index": "not_analyzed"
},
"invisible": {"type": "boolean"},
"blocked": {"type": "boolean"}
}
}
}
}

{
"id":"1",
"timestamp":"2014-08-07T20:35:40.936Z",
"location":"10.0,10.0",
"user":"@geeko",
"text":"Hello World!",
"to":"WORLD",
"invisible":false,
"blocked":false
}

最佳答案

实际上,这是由于我对nodejs客户端使用不当造成的。
我使用的是客户端搜索功能提供的sort属性(这相当于不接受_geo_distance之类的URL中排序),我应该在查询主体中使用sort属性。

关于sorting - Elasticsearch _geo_distance排序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25195556/

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