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

标签 elasticsearch

我正在建立多搜索请求,以查找与其他位置相似的位置(但有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/

相关文章:

用于对文档进行分类的 Elasticsearch 插件

elasticsearch - Kibana发现:搜索特殊字符: '@'

elasticsearch - 如何使用带有 ES 后端的 grafana 获取系列中的最后一个值

java - Elasticsearch for Jira-like System with Permissions

logging - Kibana 拆分 URL

elasticsearch - 如何在elasticsearch中获取不同的文档

elasticsearch - 关于 ElasticSearch jdbc river

java - 使用java在 Elasticsearch 中创建自定义停用词列表

elasticsearch - 如果在 [基本] 许可证上启用了安全性,则必须启用传输 SSL

elasticsearch - Elasticsearch “max_ngram_diff”适用于 “edge_ngram”,但不适用于 “ngram_tokenizer”