From c9edc866f87eb8f27b4a3597e41d8105f78c5880 Mon Sep 17 00:00:00 2001 From: RasonJ <145287540+RasonJ@users.noreply.github.com> Date: Thu, 30 May 2024 20:04:26 -0700 Subject: [PATCH] updates --- _search-plugins/ubi/client-data-structures.md | 95 ------------------- _search-plugins/ubi/documentation.md | 60 +----------- _search-plugins/ubi/ubi-dashboard-tutorial.md | 6 +- 3 files changed, 5 insertions(+), 156 deletions(-) delete mode 100644 _search-plugins/ubi/client-data-structures.md diff --git a/_search-plugins/ubi/client-data-structures.md b/_search-plugins/ubi/client-data-structures.md deleted file mode 100644 index 267c99883a..0000000000 --- a/_search-plugins/ubi/client-data-structures.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -layout: default -title: Client Data structures old -parent: User behavior insights -has_children: false -nav_order: 7 ---- -TODO: merge with data-structures.md - - -The data structures that we use for indexing events adhere to the following nested structure that aligns with the UBI schemas. See the [schemas]({{site.url}}{{site.baseurl}}/search-plugins/ubi/schemas/) for descriptions and examples of the following fields. - -`struct UbiEvent {` -- application -- action_name -- user_id -- query_id -- session_id -- page_id -- message_type -- timestamp --
- event_attributes { -

- - -

- position { - - - ordinal - - x - - y - - trail - } -
- -
- object { - - - internal_id - - object_id - - object_type - - description - - object_details / - - object_details.json - } -
- } -
} -`}` - -Typescript versions of these classes can be found in [here](#TODO-clients-link-ts) - -Example JavaScript code: -```js - // basic message format - let e = new UbiEvent('chorus', 'add_to_cart', user_id, query_id); - e.message_type = 'PURCHASE'; - e.message = item.title + ' (' + item.primary_ean + ')'; - e.session_id = session_id; - e.page_id = window.location.pathname; - - // adding custom data fields - e.event_attributes['user_info'] = {user_name:'TheJackal', phone:'555-555-1234'} - - // associate the object added to the cart - e.event_attributes.object = new UbiObject('product', item.primary_ean, item.title, item); - - // save any click info - e.event_attributes.position = new UbiPosition({x:event.clientX, y:event.clientY}); - - // index here - console.log(e.toJson()); -``` - -With very similar [Python data structures](#TODO-clients-link) -```python -if __name__ == '__main__': - e = UbiEvent(application='chorus', action_name='add_to_cart', - user_id='USER-' + guuid(), query_id='QUERY-ID-'+ guuid(), session_id='SESSION-' + guuid(), - # object added to the cart - object= UbiObject( - object_type='product', - object_id='ISBN-' + guuid(), - description='a very nice book', details={'product_data':'random product data'} - ) - ) - e.message_type = 'PURCHASE' - - # adding custom attribute fields - e.event_attributes['user_info'] = {'user_name':'TheJackal', 'phone':'555-555-1234'} - - # product position information - e.event_attributes.position = UbiPosition(ordinal=3, x=250, y=400) - - print(e.to_json()) -``` diff --git a/_search-plugins/ubi/documentation.md b/_search-plugins/ubi/documentation.md index 32c5b25f2b..aa926bab80 100644 --- a/_search-plugins/ubi/documentation.md +++ b/_search-plugins/ubi/documentation.md @@ -18,8 +18,8 @@ to improve search relevance and user experience. ## UBI store -The plugin has a concept of a "store", which is a logical collection of the events and queries. A store consists of two indexes. One -index is used to store events, and the other index is for storing queries. +The plugin has a concept of a "store", which is a logical collection of the events and queries. A store consists of two indexes. +One index is used to store events, and the other index is for storing queries. ### OpenSearch data mappings UBI has 2 primary indexes: @@ -29,62 +29,6 @@ UBI has 2 primary indexes: ## Plugin API -The plugin exposes a REST API for managing UBI stores and persisting events. - -| Method | Endpoint | Purpose | -|--------|-----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `PUT` | `/_plugins/ubi/{store}?index={index}&object_id={object_id}` |

Initialize a new UBI store for the given index. The `object_id` is optional and allows for providing the name of a field in the `index`'s schema to be used as the unique result/item ID for each search result. If not provided, the `_id` field is used.

| -| `DELETE` | `/_plugins/ubi/{store}` | Delete a UBI store | -| `GET` | `/_plugins/ubi` | Get a list of all UBI stores | -| `POST` | `/_plugins/ubi/{store}` | Index an event into the UBI store | -| `TRACE` | `/_plugins/ubi` | For temporary developer debugging | - -### Creating a UBI store - -To create a UBI store to contain events and queries, send a `PUT` request: - -``` -PUT http://localhost:9200/_plugins/ubi/mystore?index=ecommerce -``` -{% include copy-curl.html %} - -### Deleting a UBI store - -To delete a store, send a `DELETE` request: - -``` -DELETE http://localhost:9200/_plugins/ubi/mystore -``` -{% include copy-curl.html %} - -This will delete the UBI store and all contained events and queries. Use this with caution. - -### Get a list of UBI stores - -To get a list of stores, send a `GET` request: - -``` -GET http://localhost:9200/_plugins/ubi -``` -{% include copy-curl.html %} - -### Persist a client-side event into a UBI store - -To persist a client-side event into a store, send a `POST` request where the body of the request is the event: - -``` -http://localhost:9200/_plugins/ubi/mystore -H "Content-Type: application/json" -d ' -{ - "action_name": "search", - "user_id": "98fcf189-4fa8-4322-b6f5-63fbb6b556c9", - "timestamp": 1705596607509 -}' -``` -{% include copy-curl.html %} - -## Capturing queries with UBI - -You enable the UBI data capture for a query on a query by query basis by adding the parameter `"ubi":true` to your query. ### Associating a query with client-side events diff --git a/_search-plugins/ubi/ubi-dashboard-tutorial.md b/_search-plugins/ubi/ubi-dashboard-tutorial.md index b7845c6517..8b7a1be254 100644 --- a/_search-plugins/ubi/ubi-dashboard-tutorial.md +++ b/_search-plugins/ubi/ubi-dashboard-tutorial.md @@ -17,12 +17,12 @@ Depending on your configuration: http://localhost:5601/app/home#/ ## 2) Create an index pattern http://localhost:5601/app/management/opensearch-dashboards/indexPatterns ![Index Patterns]({{site.url}}{{site.baseurl}}/images/ubi/index_pattern1.png "Index Patterns") -Index patterns are how OpenSearch dashboards access your indexes. In this case, we want to access the *hidden* indexes that UBI creates, so that we can visualize your users' online, search behaviors. +Index patterns are how OpenSearch dashboards access your indexes. In this case, we want to access the indexes that UBI creates, so that we can visualize your users' online, search behaviors. -After you click on "Create index pattern" you'll see a list of indexes in your OpenSearch instance. The UBI stores are hidden by default; so, be sure to click on "Include system and hidden indexes". +After you click on "Create index pattern" you'll see a list of indexes in your OpenSearch instance. The UBI stores may be hidden by default; so, be sure to click on "Include system and hidden indexes". ![Index Patterns]({{site.url}}{{site.baseurl}}/images/ubi/index_pattern2.png "Index Patterns") -With wildcards you can group indexes into the same data source for your dashboard. Assuming the name of your UBI is `chorus`, we'll lump both the query and event stores together as `ubi_chorus*`. +With wildcards you can group indexes into the same data source for your dashboard. So we'll lump both the query and event stores together as `ubi_*`. It will prompt you to filter on any `date` field in your schema, so that you can look at things like trending queries over the last 15 minutes. However, for your first dashboard, do not filter on any date field. Index Patterns