Created
June 30, 2014 09:58
-
-
Save yinchunxiang/b887fdc025bac87eafc6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SELECT COUNT(*) from bank GROUP BY state ORDER BY COUNT(*) DESC | |
curl -XPOST 'localhost:9200/bank/_search?pretty' -d ' | |
{ | |
"size": 0, | |
"aggs": { | |
"group_by_state": { | |
"terms": { | |
"field": "state" | |
} | |
} | |
} | |
}' | |
# This example demonstrates how we can group by age brackets (ages 20-29, 30-29, and 40-49), | |
# then by gender, and then finally get the average account balance, per age bracket, per gender | |
curl -XPOST 'localhost:9200/bank/_search?pretty' -d ' | |
{ | |
"size": 0, | |
"aggs": { | |
"group_by_state": { | |
"terms": { | |
"field": "state", | |
"order": { | |
"average_balance": "desc" | |
} | |
}, | |
"aggs": { | |
"average_balance": { | |
"avg": { | |
"field": "balance" | |
} | |
} | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment