简体   繁体   中英

Convert Elasticsearch kibana query string format to URI Search format

From last week I'm working with Elastic Search Service on AWS. 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. 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
        }
      }
    }
  }
}

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. How to Convert above ES query sting to URI Search format?

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

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.

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.

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

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?

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}}}}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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