Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { "userCode": "abcd123", "response": 1 }
- { "userCode": "abcd123", "response": 1 }
- { "userCode": "abcd123", "response": 0 }
- { "userCode": "wxyz123", "response": 0 }
- { "userCode": "wxyz123", "response": 0 }
- { "userCode": "wxyz123", "response": 1 }
- select userCode, response, count(*) as total
- from response_table
- group by userCode, response
- abcd123, 0, 1 //user abcd123 responded 0 once
- abcd123, 1, 2 //user abcd123 responded 1 twice
- wxyz123, 0, 2 //user wxyz123 responded 0 twice
- wxyz123, 1, 1 //user wxyz123 responded 1 once
- {
- "aggs": {
- "users": {
- "terms": { "field": "userCode" },
- "aggs": {
- "responses" : {
- "terms": { "field": "response" }
- }
- }
- }
- }
- }
- {
- "data": {
- "properties": {
- "userCode": { "type": "string", "store": "yes", "index": "analyzed", "term_vector": "no" },
- "response": { "type": "integer", "store": "yes", "index": "analyzed", "term_vector": "yes" }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement