Mugeesh Husain
Mugeesh Husain

Reputation: 428

How to convert CURL into URI in Elasticsearch

I have a curl command for elasticsearch aggregation as below.

curl -XGET "http://localhost:9200/employee/_search?search_type=count&pretty" -d '{
  "aggregations": {
    "profile": {
      "terms": {
        "field": "_type"
      },
      "aggs": {
        "hits": {
          "top_hits": {
            "size": 1
          }
        }
      }
    }
  }
}'

I want to search these above curl into my htmlpage in browser, how to convert this into normal url like URI search in elasticsearch ?

Please help me to convert above to url ?

Upvotes: 1

Views: 2986

Answers (1)

Val
Val

Reputation: 217474

You can use the source query string parameter in order to pass the body directly in the URL

curl -XGET 'http://localhost:9200/employee/_search?search_type=count&pretty&source={"aggregations":{"profile":{"terms":{"field":"_type"},"aggs":{"hits":{"top_hits":{"size":1}}}}}}'
                                                                              ^
                                                                              |
                                                           use the source parameter

Upvotes: 3

Related Questions