gpt4 book ai didi

elasticsearch - 如何告诉Elasticsearch返回带有搜索结果的搜索参数?

转载 作者:行者123 更新时间:2023-12-03 01:37:52 25 4
gpt4 key购买 nike

我正在建立多搜索请求,以查找与其他位置相似的位置(但有100个子搜索):

{}
{"query":{"filtered":{"filter":{"geo_distance":{"distance":"10m","location":{"lat":48.8643,"lon":2.3774}}}}},"size":1,"sort":[{"_geo_distance":{"location":{"lat":48.8643,"lon":2.3774},"order":"asc","unit":"m","mode":"min","distance_type":"plane"}}]}
{}
{"query":{"filtered":{"filter":{"geo_distance":{"distance":"10m","location":{"lat":49.4293,"lon":3.3734}}}}},"size":1,"sort":[{"_geo_distance":{"location":{"lat":49.4293,"lon":3.3734},"order":"asc","unit":"m","mode":"min","distance_type":"plane"}}]}

它返回如下结果:
{
"responses" : [
{
"took" : 30,
"timed_out" : false,
"hits" : {
"hits" : [
{
"sort" : [
2.48215343865
],
"_index" : "index1",
"_id" : "255610",
"_type" : "my_type",
"_source" : {
"rep" : null,
"location" : {
"lat" : 48.8645413506779,
"lon" : 2.37757252267366
},
"name" : "Fastfood 3"
},
"_score" : null
}
],
"max_score" : null,
"total" : 45
},
"_shards" : {
"total" : 4,
"failed" : 0,
"successful" : 4
}
},
{
"_shards" : {
"failed" : 0,
"successful" : 4,
"total" : 4
},
"hits" : {
"hits" : [
{
"sort" : [
89.301169725
],
"_id" : "6505",
"_index" : "index1",
"_type" : "my_type",
"_source" : {
"numero" : 1,
"location" : {
"lat" : 49.8603911006058,
"lon" : 3.37063212374192
},
"name" : "Resto 1"
},
"_score" : null
}
],
"max_score" : null,
"total" : 2117987
},
"timed_out" : false,
"took" : 120
}
]
}

我读到结果顺序与请求顺序匹配,但是可以告诉Elasticsearch将请求参数放入结果中吗?我想获取用于匹配距离过滤器的线段的两个末端位置...

最佳答案

您可以使用命名搜索:https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-named-queries-and-filters.html

通过添加:"_name" : "search_1",该名称将位于返回的命中文档中。

关于elasticsearch - 如何告诉Elasticsearch返回带有搜索结果的搜索参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50872903/

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