将 Elasticsearch kibana 查询字符串格式转换为 URI 搜索格式 [英] Convert Elasticsearch kibana query string format to URI Search format

查看:52
本文介绍了将 Elasticsearch kibana 查询字符串格式转换为 URI 搜索格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从上周开始,我开始在 AWS 上使用 Elastic Search Service.我当前的 Elasticseach 版本是 6.X.X 和 Kibana 6.X.X,现在我对 Kibana 客户端上运行的查询格式有点灵活.但我的问题是我无法将查询转换为可在 浏览器 URL/邮递员 上运行的 URI 格式.例如:如何将其转换为 URI 搜索格式?

From last week I'm working with Elastic Search Service on AWS. My current version of Elasticseach is 6.X.X and Kibana 6.X.X, Now I'm little bit flexible with the query format that runs on Kibana Client. But my problem is I'm not able to convert the queries to URI format that'll run on Browser URL/Postman. For example: How can I convert it to URI Search format?.

GET my_index/_search
{
  "query": {
    "geo_bounding_box": { 
      "location": {
        "top_left": {
          "lat": 42,
          "lon": -72
        },
        "bottom_right": {
          "lat": 40,
          "lon": -74
        }
      }
    }
  }
}

我在这里看到了有关 URI 搜索格式的文档,其中包含不同的参数,例如 qdf 等:https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-uri-request.html 但无法将上述查询字符串转换为 URI 搜索格式.实际上,我对支持 q、fq、sort、start、rows、boost、facet、group 等的 SOLR 查询格式非常灵活.所以,据我所知,弹性搜索也使用了 Lucene 索引,所以我的基本问题是

I've seen the documentation about URI Search format here with different params like q, df etc : https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-uri-request.html But not able to convert the above query string to URI search format. Actually I'm very much flexible to SOLR query format that supports q, fq, sort, start, rows, boost, facet, group etc. So, as I know that Elastic search also used Lucene Indexing so my basic question is

1. 如何将上述 ES 查询字符串转换为 URI 搜索格式?

1. How to Convert above ES query sting to URI Search format?

2. 如何轻松地将 SOLR 查询转换为 ES 格式?

2. How can I easily convert SOLR queries to ES format?

如果您帮助我将上述查询字符串转换为 URI 搜索 格式,那么将我现有的复杂 SOLR 查询转换为 ES 查询将大有帮助.

If you help me out to convert the above query string to URI Search format then it'll help me a lot to covert my existing complex SOLR queries to ES queries.

注意:我可以使用 ?q= 参数转换基本的 CRUD 操作,但很难转换其他操作,例如 facet、助推、组等.

N.B: I'm able to convert basic CRUD operations using the ?q= parameters but having difficulties to covert the others like facet, boosting, group and so on.

编辑:实际上我想说这个查询参数返回相同的文档数.都来自 solr &es - 这里我只使用 _source 作为 ES,因为我们使用 fl 作为 SOLR.否则一切都一样

Edit: Actually I want to say that this query params returns same no of docs. both from solr & es - here I just used _source for ES as we use fl for SOLR. Otherwise everything is same

https://my_host/rental_properties/_search?_source=id,code:feed_provider_id,feed_provider_id,feed,property_name,pax:occupancy,bedroom_count,min_stay,star_rating,night_rate_min,currency&q=feed:11 AND -booked_date:[2018-02-23T00:00:00Z TO 2018-02-26T00:00:00Z] AND min_stay:[* TO 3] AND occupancy:[3 TO *] AND -latlon:0.001,0.001

https://my_host/rental_properties/_search?_source=id,code:feed_provider_id,feed_provider_id,feed,property_name,pax:occupancy,bedroom_count,min_stay,star_rating,night_rate_min,currency&q=feed:11 AND -booked_date:[2018-02-23T00:00:00Z TO 2018-02-26T00:00:00Z] AND min_stay:[* TO 3] AND occupancy:[3 TO *] AND -latlon:0.001,0.001

Val 的回答中,我开始知道 1 我可以轻松地使用相同的查询字符串进行 URI 搜索.2.但是如何轻松地将我的 SOLR 查询转换为 ES 格式?

From the answer of Val , I came to know that 1 I can easily use the same query string for URI search. 2. But how can I convert my SOLR query to ES format easily?

推荐答案

请注意,始终可以通过将 DSL 查询放在 source 查询参数.您还需要添加 source_content_type=application/json 参数.所以你的查询看起来像这样:

Note that it is always possible to use the exact same DSL query with URI search by putting the DSL query in the source query parameter. You also need to add the source_content_type=application/json parameter. So your query would look like this:

GET my_index/_search?source_content_type=application/json&source={"query":{"geo_bounding_box":{"location":{"top_left":{"lat":42,"lon":-72},"bottom_right":{"lat":40,"lon":-74}}}}}

这篇关于将 Elasticsearch kibana 查询字符串格式转换为 URI 搜索格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆