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

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

问题描述

从上周开始,我在AWS上使用Elastic Search Service.我当前的Elasticseach版本是6.X.X和Kibana 6.X.X,现在我对在Kibana Client上运行的查询格式有点灵活性.但是我的问题是我无法将查询转换为将在浏览器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搜索格式的文档,其中包含 q df 等不同的 params 参数:

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 操作,但很难隐蔽其他方面,提升,分组等.

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

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查询放入

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天全站免登陆