Example UBI query DSL queries

You can use the OpenSearch search query language, query DSL, to write User Behavior Insights (UBI) queries. The following example returns the number of times that each action_name event occurs. For more extensive analytic queries, see Example UBI SQL queries.

Example request

  1. GET ubi_events/_search
  2. {
  3. "size":0,
  4. "aggs":{
  5. "event_types":{
  6. "terms": {
  7. "field":"action_name",
  8. "size":10
  9. }
  10. }
  11. }
  12. }

copy

Example response

  1. {
  2. "took": 1,
  3. "timed_out": false,
  4. "_shards": {
  5. "total": 1,
  6. "successful": 1,
  7. "skipped": 0,
  8. "failed": 0
  9. },
  10. "hits": {
  11. "total": {
  12. "value": 10000,
  13. "relation": "gte"
  14. },
  15. "max_score": null,
  16. "hits": []
  17. },
  18. "aggregations": {
  19. "event_types": {
  20. "doc_count_error_upper_bound": 0,
  21. "sum_other_doc_count": 0,
  22. "buckets": [
  23. {
  24. "key": "brand_filter",
  25. "doc_count": 3084
  26. },
  27. {
  28. "key": "product_hover",
  29. "doc_count": 3068
  30. },
  31. {
  32. "key": "button_click",
  33. "doc_count": 3054
  34. },
  35. {
  36. "key": "product_sort",
  37. "doc_count": 3012
  38. },
  39. {
  40. "key": "on_search",
  41. "doc_count": 3010
  42. },
  43. {
  44. "key": "type_filter",
  45. "doc_count": 2925
  46. },
  47. {
  48. "key": "login",
  49. "doc_count": 2433
  50. },
  51. {
  52. "key": "logout",
  53. "doc_count": 1447
  54. },
  55. {
  56. "key": "new_user_entry",
  57. "doc_count": 207
  58. }
  59. ]
  60. }
  61. }
  62. }

copy

You can run the preceding queries in the OpenSearch Dashboards Query Workbench.

A demo workbench with sample data can be found here: http://chorus-opensearch-edition.dev.o19s.com:5601/app/OpenSearch-query-workbench.