Reputation: 11
I am trying to execute below query in elastic search using rest call which is not providing aggregation results.But if i excute the same query in elasticsearch browser it provides aggregation results.
Query:
{ "aggregations": { "by_salary": { "terms": { "field": "salary" } } } }
Rest call:
http://localhost:9200/tcx_transaction/_search?query={ "aggregations": { "by_salary": { "terms": { "field": "salary" } } } }
Results:
"aggregations": {
"by_salary": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "manager",
"doc_count": 39420
}
,
{
"key": "developer",
"doc_count": 13140
}
,
{
"key": "HR",
"doc_count": 4380
}
]
}
}
Upvotes: 1
Views: 527
Reputation: 15136
try installing "curl" and then, from shell:
curl -XPOST 'http://localhost:9200/tcx_transaction/_search' -d
'{ "aggregations": { "by_salary": { "terms": { "field": "salary" } } } }'
Upvotes: 0
Reputation: 53496
You are misusing the REST interface. Take a peek at the parameters allowed for URI searching. query
isn't one of them. q
is but that is specifically for a very special type of query.
As pickypg mentioned, what you have set to query
should be part of the HTTP POST body.
Upvotes: 0