3

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

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.

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.

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?

A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103

1 Answers1

7

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}}}}}
Val
  • 207,596
  • 13
  • 358
  • 360
  • Thank you very much @Val . I got it what u say – A l w a y s S u n n y Jan 21 '18 at 03:18
  • 1
    Does this help? http://www.elasticsearchtutorial.com/common-solr-queries-in-elasticsearch.html – Val Jan 21 '18 at 05:19
  • Yes it helps sir. But I want to use this same format both on SOLR and ES like 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 not the json query string – A l w a y s S u n n y Jan 21 '18 at 10:24
  • That's a Lucene expression query and you can use it with ES too using the `q=` query string parameter – Val Jan 21 '18 at 16:06
  • yes I know it. One more query from you , is there any online resources that will help me easily to map between SOLR and ES query string params? e.g q is same on both ES & SOLR, from->start, size->rows, _source->fl on ES and SOLR respectively but what about other params mapping between ES and SOLR like fq, facet, group etc. – A l w a y s S u n n y Jan 22 '18 at 15:07
  • That should be the subject of another question, I guess – Val Jan 22 '18 at 15:13
  • Ok, I'll create another question on SO then – A l w a y s S u n n y Jan 22 '18 at 15:38
  • please have a look on my new question on SO here at https://stackoverflow.com/questions/48406843/convert-solr-query-to-elasticsearch-uri-format – A l w a y s S u n n y Jan 23 '18 at 16:46