Skip to content

Instantly share code, notes, and snippets.

@qvin
Last active August 29, 2015 14:00
Show Gist options
  • Save qvin/a40bd96d6df25d1b31c3 to your computer and use it in GitHub Desktop.
Save qvin/a40bd96d6df25d1b31c3 to your computer and use it in GitHub Desktop.
Elasticsearch Query with output
curl -XGET 'http://localhost:9200/testdb/testtable/_search' -d '{
"size": 0,
"aggs": {
"report_aggs": {
"filter": {
"and": [
{
"term": {
"prop1": "1"
}
},
{
"term": {
"prop2": "2"
}
},
{
"term": {
"checkflag": "true"
}
}
]
},
"aggs": {
"aggs_sum": {
"terms": {
"field": "nesteddocs.dockey"
},
"aggs": {
"docvalsum": {
"sum": {
"field": "nesteddocs.docvalue"
}
}
}
}
}
}
}
}'
---------------------- RESULT --------------------------------------------
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 5,
"max_score": 0,
"hits": []
},
"aggregations": {
"report_aggs": {
"doc_count": 2,
"aggs_sum": {
"buckets": [
{
"key": 100,
"doc_count": 2,
"docvalsum": {
"value": 1026 ---------- (EXPECTED 111+211 = 322)
}
},
{
"key": 200,
"doc_count": 2,
"docvalsum": {
"value": 1026 ---------- (EXPECTED 121+221 = 342)
}
},
{
"key": 300,
"doc_count": 2,
"docvalsum": {
"value": 1026 ---------- (EXPECTED 131+231 = 362)
}
}
]
}
}
}
}
---------------------- END RESULT --------------------------------------------
@milodky
Copy link

milodky commented Dec 18, 2014

Hi,
Did you figure out how to solve this? I ran into similar situations as you did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment