How to convert CURL into URI in Elasticsearch

淺唱寂寞╮ 提交于 2019-12-24 15:40:21

问题


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 ?


回答1:


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


来源:https://stackoverflow.com/questions/34715720/how-to-convert-curl-into-uri-in-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!