Somehow I can't seem to get a response containing my aggregations...
Using curl it works as expected:
HBZUMB01$ curl -XPOST "http://localhost:9200/contents/_search" -d '{
"size": 0,
"aggs": {
"sport_count": {
"value_count": {
"field": "dwid"
}
}
}
}'
I get the response:
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 90,
"max_score": 0.0,
"hits": []
},
"aggregations": {
"sport_count": {
"value": 399
}
}
}
However using the code in rails:
query = '{
"size": 0,
"aggs": {
"sport_count": {
"value_count": {
"field": "dwid"
}
}
}
}'
@response = Content.search(query).to_json
and rendering it in the browser
respond_to do |format|
format.html do
render text: "#{@response}"
end
I get an empty response:
[ ]
How can I print my aggregations here which I got with curl?