Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. { "userCode": "abcd123", "response": 1 }
  2. { "userCode": "abcd123", "response": 1 }
  3. { "userCode": "abcd123", "response": 0 }
  4. { "userCode": "wxyz123", "response": 0 }
  5. { "userCode": "wxyz123", "response": 0 }
  6. { "userCode": "wxyz123", "response": 1 }
  7.  
  8. select userCode, response, count(*) as total
  9. from response_table
  10. group by userCode, response
  11.  
  12. abcd123, 0, 1 //user abcd123 responded 0 once
  13. abcd123, 1, 2 //user abcd123 responded 1 twice
  14. wxyz123, 0, 2 //user wxyz123 responded 0 twice
  15. wxyz123, 1, 1 //user wxyz123 responded 1 once
  16.  
  17. {
  18. "aggs": {
  19. "users": {
  20. "terms": { "field": "userCode" },
  21. "aggs": {
  22. "responses" : {
  23. "terms": { "field": "response" }
  24. }
  25. }
  26. }
  27. }
  28. }
  29.  
  30. {
  31. "data": {
  32. "properties": {
  33. "userCode": { "type": "string", "store": "yes", "index": "analyzed", "term_vector": "no" },
  34. "response": { "type": "integer", "store": "yes", "index": "analyzed", "term_vector": "yes" }
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement