简体   繁体   English

将Elasticsearch kibana查询字符串格式转换为URI搜索格式

[英]Convert Elasticsearch kibana query string format to URI Search format

From last week I'm working with Elastic Search Service on AWS. 从上周开始,我在AWS上使用Elastic Search Service。 My current version of Elasticseach is 6.XX and Kibana 6.XX, Now I'm little bit flexible with the query format that runs on Kibana Client. 我当前的Elasticseach版本是6.XX和Kibana 6.XX,现在我对在Kibana Client上运行的查询格式有点灵活性。 But my problem is I'm not able to convert the queries to URI format that'll run on Browser URL/Postman . 但是我的问题是我无法将查询转换为将在Browser URL / Postman上运行的URI格式。 For example: How can I convert it to URI Search format?. 例如:如何将其转换为URI搜索格式?

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

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. 我在这里看到了有关URI搜索格式的文档,其中包含qdf等不同的参数https : //www.elastic.co/guide/en/elasticsearch/reference/6.0/search-uri-request.html但无法将上面的查询字符串转换为URI搜索格式。 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 实际上,我对支持q,fq,排序,开始,行,boost,facet,group等的SOLR查询格式非常灵活。因此,据我所知,弹性搜索还使用了Lucene Indexing,所以我的基本问题是

1. How to Convert above ES query sting to URI Search format? 1.如何将上述ES查询字符串转换为URI搜索格式?

2. How can I easily convert SOLR queries to ES format? 2.如何轻松将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. 如果您帮助我将上述查询字符串转换为URI搜索格式,那么将现有的复杂SOLR查询转换为ES查询将对我有很大帮助。

NB: 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. 注意:我可以使用?q =参数转换基本的CRUD操作,但是很难隐蔽其他方面,例如facet,boost,group等。

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. 两者均来自solr和es-在这里,我仅将_source用于ES,因为我们将fl用于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,代码:feed_provider_id,feed_provider_id,feed,property_name,pax:入住率,卧室数量,最小住宿,星级,night_rate_min,currency&q = feed:11 AND-预定日期:[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

From the answer of Val , I came to know that 1 I can easily use the same query string for URI search. Val的答案中,我知道1我可以轻松地将相同的查询字符串用于URI搜索。 2 . 2 But how can I convert my SOLR query to ES format easily? 但是,如何将SOLR查询轻松转换为ES格式?

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 . 请注意,始终可以通过将DSL查询放入source查询参数中来使用与URI搜索完全相同的DSL查询。 You also need to add the source_content_type=application/json parameter. 您还需要添加source_content_type=application/json参数。 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}}}}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM