不知怎的,我似乎无法得到包含我的聚合的回复......
使用curl它按预期工作:
HBZUMB01$ curl -XPOST "http://localhost:9200/contents/_search" -d '{
"size": 0,
"aggs": {
"sport_count": {
"value_count": {
"field": "dwid"
}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
我收到了回复:
{
"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
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是使用rails中的代码:
query = '{
"size": 0,
"aggs": {
"sport_count": {
"value_count": {
"field": "dwid"
}
}
}
}'
@response = Content.search(query).to_json
Run Code Online (Sandbox Code Playgroud)
并在浏览器中呈现它
respond_to do |format| …Run Code Online (Sandbox Code Playgroud)