lmenezes / elasticsearch-kopf

web admin interface for elasticsearch
MIT License
2.41k stars 332 forks source link

Sending Request Data in REST #376

Closed sundarv85 closed 8 years ago

sundarv85 commented 8 years ago

Hello,

Using Sense, one can do a GET with a particular query, such as

GET /_search
{
  "query": {
    "bool": {
      "should": [
        {
          "term": {
            "status": {
              "value": "urgent",
              "boost": 2.0 
            }
          }
        },
        {
          "term": {
            "status": "normal" 
          }
        }
      ]
    }
  }
}

How to do this in Kopf REST. I see issue 12 that REST GET, will not take any data.

robison commented 8 years ago

You can use POST instead of GET for this request. According to most current interpretations of RFC2616, GET requests must encode any request data in the Request-URI, and not the body.

lmenezes commented 8 years ago

@sundarv85 hey even though ES does support GET requests with a body, I thought it actually made more sense to disregard the body in a GET request(this way, you don't have to have a valid JSON if you just want to execute a simple _search for example), as ES also allows you to do the same using POST.