0

the following code snippet doesn't make sense to me.

curl -XGET 'localhost:9200/bank/_search?pretty' -H 'Content-Type: application/json' -d'
{
  "query": { "match_phrase": { "address": "mill lane" } }
}
'

Does HTTP GET contain a body (data)?

cdhit
  • 1,384
  • 1
  • 15
  • 38

2 Answers2

0

No, GET takes only a QUERY_STRING, but no data.

Usually data are sent via POST or PUT HTTP verbs

Check http://www.restapitutorial.com/lessons/httpmethods.html

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
  • In my example, it does take data. The query is not a querystring. This is an official example of the ElasticSearch. – cdhit Feb 15 '18 at 21:43
  • Having a reference link please ? – Gilles Quénot Feb 15 '18 at 21:46
  • Here you go! https://www.elastic.co/guide/en/elasticsearch/reference/6.2/_executing_searches.html – cdhit Feb 15 '18 at 23:12
  • Very confusing me, check https://stackoverflow.com/questions/6073896/sending-json-object-to-the-server-via-http-get – Gilles Quénot Feb 15 '18 at 23:22
  • "Sending JSON object to the server via http GET" this is confusing me. My question is how this scenario can exist, however, it does exist. By the way, I didn't get the answer from that thread. – cdhit Feb 16 '18 at 01:26
0

I found the answer here! In the ElasticSearch Docs.

https://www.elastic.co/guide/en/elasticsearch/guide/current/_empty_search.html

The HTTP libraries of certain languages (notably JavaScript) don’t allow GET requests to have a request body. In fact, some users are surprised that GET requests are ever allowed to have a body.

...

cdhit
  • 1,384
  • 1
  • 15
  • 38