Reputation: 575
can someone please advise how can I convert this JSON body into a REST URI ?
GET api/_search
{
"age":"5",
"aggs" : {
"uniq_gender" : {
"terms" : { "field" : "Gender.keyword" }
}
}
}
Upvotes: 0
Views: 355
Reputation: 2314
You may proceed with one of two options:
Use POST
with body
POST api/_search
{
"age":"5",
"aggs" : {
"uniq_gender" : {
"terms" : { "field" : "Gender.keyword" }
}
}
}
It may seem like a hack, but it is simple and frankly it is widely used. Basically from REST
perspective it may be considered as resource creation (filter
rather than seach
might be a better word here).
GET
.Something like:
GET api/_search?age=5,field=Gender.keyword
The problem with using query string is that it may be limited. In RFC there is a code for such a case. For example IE browser has such a limit - see details.
Generally speaking if there is no technical problem, readability issue may appear - it is hard to deal with 1000+ symbols string.
Upvotes: 1