Skip to content

Commit

Permalink
Minor tweaks. Moved Ubi under SEARCH.
Browse files Browse the repository at this point in the history
  • Loading branch information
RasonJ committed May 22, 2024
1 parent 46cc0d9 commit 4e2a617
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 19 deletions.
8 changes: 5 additions & 3 deletions _search-plugins/ubi/client-data-structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ 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/schemas/) for descriptions and examples of the following fields.

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
Expand Down Expand Up @@ -45,7 +47,7 @@ The data structures that we use for indexing events adhere to the following nest
</details>}
`}`

Typescript versions of these classes can be found in [ts/UbiEvent.ts](./ts/UbiEvent.ts).
Typescript versions of these classes can be found in [here](#TODO-clients-link-ts)

Example JavaScript code:
```js
Expand All @@ -69,7 +71,7 @@ Example JavaScript code:
console.log(e.toJson());
```

With very similar [Python data structures](./py/ubi.py):
With very similar [Python data structures](#TODO-clients-link)
```python
if __name__ == '__main__':
e = UbiEvent(application='chorus', action_name='add_to_cart',
Expand Down
18 changes: 6 additions & 12 deletions _search-plugins/ubi/data-structures.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: default
title: Client data structures
title: UBI client data structures
parent: User behavior insights
has_children: false
nav_order: 7
Expand All @@ -12,14 +12,8 @@ The client data structures can be used to create events that follow the [UBI eve
The developer provides an implementation for the following functions:
- `getClientId()`
- `getQueryId()`
- `getSessionId()`
- `getPageId()`- e.g.:
```js
function getPageId(){
return location.pathname;
}
```
Other sample implementations can be found [here](#TODO).

Other sample implementations can be found [here](#TODO-clients-link).

```js
/*********************************************************************************************
Expand Down Expand Up @@ -74,10 +68,8 @@ export class UbiEventAttributes {
export class UbiEvent {
constructor(action_name, {message=null, event_attributes={}, data_object={}}={}) {
this.action_name = action_name;
this.user_id = getUserId();
this.client_id = getClientID();
this.query_id = getQueryId();
this.session_id = getSessionId();
this.page_id = getPageId();
this.timestamp = Date.now();

this.message_type = 'INFO';
Expand Down Expand Up @@ -110,6 +102,7 @@ export class UbiEvent {
}
}
```
{% include copy.html %}

# Sample usage

Expand All @@ -124,3 +117,4 @@ export async function logDwellTime(action_name, page, seconds){
logEvent(e);
}
```
{% include copy.html %}
85 changes: 85 additions & 0 deletions _search-plugins/ubi/dsl-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,90 @@ nav_order: 8

# Sample UBI using OpenSearch DSL queries



```json
GET .ubi_log_events/_search
{
"size":0,
"aggs":{
"event_types":{
"terms": {
"field":"action_name",
"size":10
}
}
}
}
```
{% include copy.html %}

returns
```json
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 10000,
"relation": "gte"
},
"max_score": null,
"hits": []
},
"aggregations": {
"event_types": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "brand_filter",
"doc_count": 3084
},
{
"key": "product_hover",
"doc_count": 3068
},
{
"key": "button_click",
"doc_count": 3054
},
{
"key": "product_sort",
"doc_count": 3012
},
{
"key": "on_search",
"doc_count": 3010
},
{
"key": "type_filter",
"doc_count": 2925
},
{
"key": "login",
"doc_count": 2433
},
{
"key": "logout",
"doc_count": 1447
},
{
"key": "new_user_entry",
"doc_count": 207
}
]
}
}
}
```
{% include copy.html %}

These can be performed on the OpenSearch Dashboards/Query Workbench:
http://chorus-opensearch-edition.dev.o19s.com:5601/app/opensearch-query-workbench

Check failure on line 97 in _search-plugins/ubi/dsl-queries.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/dsl-queries.md#L97

[Vale.Terms] Use 'OpenSearch' instead of 'opensearch'.
Raw output
{"message": "[Vale.Terms] Use 'OpenSearch' instead of 'opensearch'.", "location": {"path": "_search-plugins/ubi/dsl-queries.md", "range": {"start": {"line": 97, "column": 15}}}, "severity": "ERROR"}

Check failure on line 97 in _search-plugins/ubi/dsl-queries.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/dsl-queries.md#L97

[Vale.Terms] Use 'OpenSearch' instead of 'opensearch'.
Raw output
{"message": "[Vale.Terms] Use 'OpenSearch' instead of 'opensearch'.", "location": {"path": "_search-plugins/ubi/dsl-queries.md", "range": {"start": {"line": 97, "column": 56}}}, "severity": "ERROR"}
8 changes: 4 additions & 4 deletions _search-plugins/ubi/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
layout: default
title: User behavior insights
parent: Search relevance
has_children: false
nav_order: 1
has_children: true
nav_order: 90
redirect_from:
- /search-plugins/ubi/
---
Expand All @@ -15,7 +14,8 @@ It is a causal system, linking a user's query to all subsequent user interaction
* An machine readable [schema](https://github.com/o19s/ubi) that faciliates interoperablity of the UBI specification.
* An OpenSearch [plugin](https://github.com/o19s/opensearch-ubi) that facilitates the storage of client-side events and queries.
* A client-side JavaScript library reference implementation that shows how to capture events and send those events to the OpenSearch UBI plugin.
TODO: link a client implementation

TODO: link a client implementation [here](#TODO-clients-link)
{: .warn }

<!-- vale off -->
Expand Down

0 comments on commit 4e2a617

Please sign in to comment.