Skip to content

Commit

Permalink
more vale violations
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed May 22, 2024
1 parent 92d84b1 commit 84f9395
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions _search-plugins/ubi/data-structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ has_children: false
nav_order: 7
---

# Sample Client data structures
The client data structures can be used to create events that follow the [UBI event schema]({{site.url}}{{site.baseurl}}/search-plugins/ubi/schemas).
# Sample client data structures
The client data structures can be used to create events that follow the [UBI event schema]({{site.url}}{{site.baseurl}}/search-plugins/ubi/schemas/).

The developer provides an implementation for the following functions:
- `getClientId()`
Expand Down
12 changes: 6 additions & 6 deletions _search-plugins/ubi/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ The plugin has a concept of a "store", which is a logical collection of the even
index is used to store events, and the other index is for storing queries.

### OpenSearch data mappings
Ubi has 2 primary indexes:
UBI has 2 primary indexes:
- **UBI Queries** stores all queries and results.
- **UBI Events** store that the Ubi client writes events to.

Check failure on line 95 in _search-plugins/ubi/documentation.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/documentation.md#L95

[OpenSearch.Spelling] Error: Ubi. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.
Raw output
{"message": "[OpenSearch.Spelling] Error: Ubi. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.", "location": {"path": "_search-plugins/ubi/documentation.md", "range": {"start": {"line": 95, "column": 33}}}, "severity": "ERROR"}
*Follow the [schema deep dive]({{site.url}}{{site.baseurl}}/search-plugins/ubi/schemas) to understand how these two indexes make UBI into a causal framework for search.*
*Follow the [schema deep dive]({{site.url}}{{site.baseurl}}/search-plugins/ubi/schemas/) to understand how these two indexes make UBI into a causal framework for search.*

## Plugin API

Expand Down Expand Up @@ -125,9 +125,9 @@ DELETE http://localhost:9200/_plugins/ubi/mystore
```
{% include copy-curl.html %}

This will delete the UBI store and all contained events and queries. Please use this with caution.
This will delete the UBI store and all contained events and queries. Use this with caution.

### Get a List of UBI stores
### Get a list of UBI stores

To get a list of stores, send a `GET` request:

Expand All @@ -136,7 +136,7 @@ GET http://localhost:9200/_plugins/ubi
```
{% include copy-curl.html %}

### Persist a Client-Side Event into a UBI store
### 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:

Expand All @@ -162,7 +162,7 @@ the plugin cannot associate a query with the client-side events associated with
To make this association, queries need to have a header value that indicates the user ID.


### Example Queries
### Example queries

The following query tells the plugin that the query being run should be persisted to the store `mystore` and be associated with user ID `john`:

Expand Down
36 changes: 18 additions & 18 deletions _search-plugins/ubi/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ nav_order: 7
UBI is not functional unless the links between the following are consistently maintained within your UBI-enabled application:

- [`user_id`](#user_id) represents a unique user.
- [`object_id`](#object_id) represents an id for whatever item the user is searching for, such as `epc`, `isbn`, `ssn`, `handle`, etc.
- [`object_id`](#object_id) represents an id for whatever item the user is searching for, such as `epc`, `isbn`, `ssn`, `handle`.
- [`query_id`](#query_id) is a unique id for the raw query language executed and the resultant `object_id`'s that the query returned. \
- [`action_name`](#action_name), though not technically an *id*, the `action_name` tells us what exact action (such as `click` or `add_to_cart`) was taken (or not) with this `object_id`.

To summarize: the `query_id` signals the beginning of a `user_id`'s *Search Journey*, the `action_name` tells us how the user is interacting with the query results within the application, and [`event_attributes.object.object_id`](#object_id) is referring to the precise query result that the user interacts with.

## UBI roles
- **Search Client**: in charge of searching, and then recieving *objects* from some document index in OpenSearch.
(1, 2, *5* and 7, below)
(1, 2, *5* and 7, in following sections)
- **User Behavior Insights** module: once activated, manages the **UBI Queries** store in the background, indexing each underlying, technical, DSL, index query with a unique [`query_id`](#query_id) along with all returned resultant [`object_id`](#object_id)'s, and then passing the `query_id` back to the **Search Client** so that events can be linked to this query.
(3, 4 and *5*, below)
- **objects**: are whatever items the user is searching for with the queries. Activating UBI involves mapping your real-world objects (via its `isbn`, `ssn`) to the [`object_id`](#object_id) fields in the schemas below.
(3, 4 and *5*, in following sections)
- **objects**: are whatever items the user is searching for with the queries. Activating UBI involves mapping your real-world objects (using it's `isbn`, `ssn`) to the [`object_id`](#object_id) fields in the schemas.
- The **Search Client**, if separate from the **UBI Client**, forwards the indexed [`query_id`](#query_id) to the **UBI Client**.
  *Note:* We break out the roles of *search* and *UBI event indexing* here, but many implementations will likely use the same OpenSearch client instance for both roles of searching and index writing.
 (6, below)
 (6, following section)
- The **UBI Client** then indexes all user events with this [`query_id`](#query_id) until a new search is performed, and a new `query_id` is generated by **User Behavior Insights** and passed back to the **UBI Client**
- If the **UBI Client** interacts with a result *object*, such as `onClick`, that [`object_id`](#object_id), *onClick* [`action_name`](#action_name) and `query_id` are all indexed together, signalling the causal link between the *search* and the *object*.
(8 and 9, below)
- If the **UBI Client** interacts with a result *object*, such as `onClick`, that [`object_id`](#object_id), `onClick` [`action_name`](#action_name) and `query_id` are all indexed together, signalling the causal link between the *search* and the *object*.
(8 and 9, following section)



Expand Down Expand Up @@ -112,10 +112,10 @@ The only obvious difference will be in the `ubi` stanze of the json response, *w
Since UBI manages the **UBI Queries** store, the developer should never have to write directly to this store (except for importing data).

- `timestamp`
  A unix timestamp of when the query was received
  A UNIX timestamp of when the query was received

- `query_id`
  A unique ID of the query provided by the client or generated automatically. The same query text issued multiple times would generate different `query_id`.
  A unique ID of the query provided by the client or generated automatically. The same query text issued multiple times would generate different `query_id`.

- `user_id`
  A user ID provided by the client
Expand All @@ -128,17 +128,17 @@ Since UBI manages the **UBI Queries** store, the developer should never have to



### 2) **UBI Events**
### 2) **UBI events**
This is the event store that the client side directly indexes events to, linking the event [`action_name`](#action_name), [`object_id`](#object_id)'s and [`query_id`](#query_id)'s together with any other important event information.
Since this schema is dynamic, the developer can add any new fields and structures (such as *user* information, *geo-location* information, etc.) at index time that are not in the current **UBI Events** [schema](../src/main/resources/events-mapping.json):
Since this schema is dynamic, the developer can add any new fields and structures (such as *user* information, *geo-location* information) at index time that are not in the current **UBI Events** [schema](../src/main/resources/events-mapping.json):
- `application`
<p id="application">

&ensp; (size 100) - name of the application tracking UBI events (e.g. *amazon-shop*, *ABC-microservice*)
&ensp; (size 100) - name of the application tracking UBI events (e.g. `amazon-shop`, `ABC-microservice`)
- `action_name`
<p id="action_name">

&ensp; (size 100) - any name you want to call your event. For example, with *javascript* events, you could include `on_click`, `logon`, `add_to_cart`, `page_scroll`.... _This should be formalized. A list of standard ones and then custom ones._
&ensp; (size 100) - any name you want to call your event. For example, with *JavaScript* events, you could include `on_click`, `logon`, `add_to_cart`, `page_scroll`.... _This should be formalized. A list of standard ones and then custom ones._

Check failure on line 141 in _search-plugins/ubi/schemas.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/schemas.md#L141

[OpenSearch.SpacingPunctuation] There should be no space before and one space after the punctuation mark in 'event. For'.
Raw output
{"message": "[OpenSearch.SpacingPunctuation] There should be no space before and one space after the punctuation mark in 'event. For'.", "location": {"path": "_search-plugins/ubi/schemas.md", "range": {"start": {"line": 141, "column": 54}}}, "severity": "ERROR"}

Check failure on line 141 in _search-plugins/ubi/schemas.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/schemas.md#L141

[OpenSearch.SpacingPunctuation] There should be no space before and one space after the punctuation mark in 'formalized. A'.
Raw output
{"message": "[OpenSearch.SpacingPunctuation] There should be no space before and one space after the punctuation mark in 'formalized. A'.", "location": {"path": "_search-plugins/ubi/schemas.md", "range": {"start": {"line": 141, "column": 192}}}, "severity": "ERROR"}

- `query_id`
<p id="query_id">
Expand All @@ -150,7 +150,7 @@ Since this schema is dynamic, the developer can add any new fields and structure
The `user_id` must be consistent in both the **UBI Queries** and **UBI Events** stores.

- `timestamp`:
&ensp; UTC-based, unix epoch time.
&ensp; UTC-based, UNIX epoch time.

- `message_type`

Expand All @@ -164,7 +164,7 @@ Since this schema is dynamic, the developer can add any new fields and structure

- `event_attributes`'s structure is where any relevant information about the event can be stored.
There are two primary structures in the `event_attributes`:
- **`event_attributes.position`** - structure that contains information on the location of the event origin, such as screen *x,y* coordinates, or the *n*th object out of 10 results, ....
- **`event_attributes.position`** - structure that contains information on the location of the event origin, such as screen *x,y* coordinates, or the *n-th* object out of 10 results, ....

Check failure on line 167 in _search-plugins/ubi/schemas.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/schemas.md#L167

[OpenSearch.SpacingPunctuation] There should be no space before and one space after the punctuation mark in 'x,y'.
Raw output
{"message": "[OpenSearch.SpacingPunctuation] There should be no space before and one space after the punctuation mark in 'x,y'.", "location": {"path": "_search-plugins/ubi/schemas.md", "range": {"start": {"line": 167, "column": 128}}}, "severity": "ERROR"}

- `event_attributes.position.ordinal`

Expand All @@ -188,12 +188,12 @@ Since this schema is dynamic, the developer can add any new fields and structure

<p id="object_id">

- **`event_attributes.object`**, which contains identifying information of the object returned from the query that the user interacts with (i.e.: a book, a product, a post, etc..).
- **`event_attributes.object`**, which contains identifying information of the object returned from the query that the user interacts with (i.e.: a book, a product, a post).
The `object` structure has two ways to refer to the object, with `object_id` being the id that links prior queries to this object:

- `event_attributes.object.internal_id` is a unique id that OpenSearch can use to internally to index the object, think the `_id` field in the indices.
- `event_attributes.object.internal_id` is a unique id that OpenSearch can use to internally to index the object, think the `_id` field in the indexes.
- `event_attributes.object.object_id`
&ensp; is the id that a user could look up amd find the object instance within the **document corpus**. Examples include: *ssn*, *isbn*, *primary_ean*. Variants need to be incorporated in the `object_id`, so for a t-shirt that is red, you would need SKU level as the `object_id`.
&ensp; is the id that a user could look up amd find the object instance within the **document corpus**. Examples include: `ssn`, `isbn`, `ean`. Variants need to be incorporated in the `object_id`, so for a t-shirt that is red, you would need SKU level as the `object_id`.

Check failure on line 196 in _search-plugins/ubi/schemas.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/schemas.md#L196

[OpenSearch.Spelling] Error: amd. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.
Raw output
{"message": "[OpenSearch.Spelling] Error: amd. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.", "location": {"path": "_search-plugins/ubi/schemas.md", "range": {"start": {"line": 196, "column": 52}}}, "severity": "ERROR"}
Initializing UBI requires mapping from the **Document Index**'s primary key to this `object_id`

- `event_attributes.object.object_type`
Expand Down
14 changes: 7 additions & 7 deletions _search-plugins/ubi/ubi_dashboard_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nav_order: 7
---

# Build an analytic dashboard for UBI
Whether you've been collecting user events and queries for a while, or [you uploaded some sample events](https://github.com/o19s/chorus-opensearch-edition/blob/main/katas/003_import_preexisting_event_data.md), now you're ready to visualize them in the dashboard!
Whether you've been collecting user events and queries for a while, or [you uploaded some sample events](https://github.com/o19s/chorus-opensearch-edition/blob/main/katas/003_import_preexisting_event_data.md), now you're ready to visualize them in the dashboard using User Behavior Insights.

Check failure on line 10 in _search-plugins/ubi/ubi_dashboard_tutorial.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/ubi_dashboard_tutorial.md#L10

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


## 1) Fire up the OpenSearch dashboards
Expand Down Expand Up @@ -47,11 +47,11 @@ Most of the visualization require some sort of aggregate function on an bucket/f
Save that visualization and it will be added to your new dashboard. Now that you have a visualization on your dashboard, you can save your dashboard.

## 4) Add a "Tag Cloud" vizualization to your dashboard

Check failure on line 49 in _search-plugins/ubi/ubi_dashboard_tutorial.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/ubi_dashboard_tutorial.md#L49

[OpenSearch.HeadingCapitalization] '4) Add a "Tag Cloud" vizualization to your dashboard' is a heading and should be in sentence case.
Raw output
{"message": "[OpenSearch.HeadingCapitalization] '4) Add a \"Tag Cloud\" vizualization to your dashboard' is a heading and should be in sentence case.", "location": {"path": "_search-plugins/ubi/ubi_dashboard_tutorial.md", "range": {"start": {"line": 49, "column": 4}}}, "severity": "ERROR"}
Let's add a word cloud for trending searches. Choose the Tag Cloud visualization of the terms in the `message` field where the javascript client logs the raw text that the user searches on. (Note: the true query, as processed by OpenSearch with filters, boosting, etc. will be in the `.{store}_queries` index, but what we are looking at is the `message` field of the `.{store}_events` index, where the javascript client captures what the user actually typed. )
Let's add a word cloud for trending searches. Choose the Tag Cloud visualization of the terms in the `message` field where the javascript client logs the raw text that the user searches on. (Note: the true query, as processed by OpenSearch with filters, boosting, and so on will be in the `.{store}_queries` index, but what we are looking at is the `message` field of the `.{store}_events` index, where the JavaScript client captures what the user actually typed. )

Check failure on line 50 in _search-plugins/ubi/ubi_dashboard_tutorial.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/ubi_dashboard_tutorial.md#L50

[Vale.Terms] Use 'JavaScript' instead of 'javascript'.
Raw output
{"message": "[Vale.Terms] Use 'JavaScript' instead of 'javascript'.", "location": {"path": "_search-plugins/ubi/ubi_dashboard_tutorial.md", "range": {"start": {"line": 50, "column": 128}}}, "severity": "ERROR"}
![Word Cloud]({{site.url}}{{site.baseurl}}/images/ubi/tag_cloud1.png "Word Cloud")

**But there's a problem!** The `message` field is on *every* event --not just query/search events-- and can be used in anyway the client developer decides to use it; so, it can contain error messages, debug messages, click information, etc.
We need to add a filter to only see search terms on query events. Since the developer gave a `message_type` of `QUERY` for each search event, we will filter on that message type to isolate just the users' searches.
**But there's a problem!** The `message` field is on *every* event --not only query/search events-- and can be used in anyway the client developer decides to use it; so, it can contain error messages, debug messages, click information, and so on.
We need to add a filter to only see search terms on query events. Since the developer gave a `message_type` of `QUERY` for each search event, we will filter on that message type to isolate the specific users' searches.
![Word Cloud]({{site.url}}{{site.baseurl}}/images/ubi/tag_cloud2.png "Word Cloud")

You should now have two visualizations on your dashboard.
Expand All @@ -62,15 +62,15 @@ To add a histogram, first, add a vertical bar chart.

<img src="{{site.url}}{{site.baseurl}}/images/ubi/visualizations2.png" alt="Vertical Bar Chart" width="300"/>

The data field we want to examine is `event_attributes.position.ordinal`, meaning the user clicked on the *n*th item in a list. The y-axis will be the number of times that *n*th was clicked. The x-axis will be the ordinal number itself that was clicked, using the `Histogram` aggregation.
The data field we want to examine is `event_attributes.position.ordinal`, meaning the user clicked on the *n*th item in a list. The y-axis will be the number of times that *n-th* was clicked. The x-axis will be the ordinal number itself that was clicked, using the `Histogram` aggregation.

Check failure on line 65 in _search-plugins/ubi/ubi_dashboard_tutorial.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/ubi_dashboard_tutorial.md#L65

[OpenSearch.Spelling] Error: th. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.
Raw output
{"message": "[OpenSearch.Spelling] Error: th. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.", "location": {"path": "_search-plugins/ubi/ubi_dashboard_tutorial.md", "range": {"start": {"line": 65, "column": 110}}}, "severity": "ERROR"}

![Vertical Bar Chart]({{site.url}}{{site.baseurl}}/images/ubi/histogram.png "Vertical Bar Chart")

## 6) Have fun slicing and dicing!
## 6) Have fun slicing and dicing
For example, let's see how the click position changes when there is a purchase, by adding this filter `action_name:product_purchase`.
![Product Purchase]({{site.url}}{{site.baseurl}}/images/ubi/product_purchase.png "Product Purchase")

Or let's see what event messages include "\*UBI\*" somewhere between the wildcards.

Check warning on line 73 in _search-plugins/ubi/ubi_dashboard_tutorial.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/ubi_dashboard_tutorial.md#L73

[OpenSearch.AcronymParentheses] 'UBI': Spell out acronyms the first time that you use them on a page and follow them with the acronym in parentheses. Subsequently, use the acronym alone.
Raw output
{"message": "[OpenSearch.AcronymParentheses] 'UBI': Spell out acronyms the first time that you use them on a page and follow them with the acronym in parentheses. Subsequently, use the acronym alone.", "location": {"path": "_search-plugins/ubi/ubi_dashboard_tutorial.md", "range": {"start": {"line": 73, "column": 45}}}, "severity": "WARNING"}
![UBI]({{site.url}}{{site.baseurl}}/images/ubi/ubi.png "UBI")

Check warning on line 74 in _search-plugins/ubi/ubi_dashboard_tutorial.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/ubi_dashboard_tutorial.md#L74

[OpenSearch.AcronymParentheses] 'UBI': Spell out acronyms the first time that you use them on a page and follow them with the acronym in parentheses. Subsequently, use the acronym alone.
Raw output
{"message": "[OpenSearch.AcronymParentheses] 'UBI': Spell out acronyms the first time that you use them on a page and follow them with the acronym in parentheses. Subsequently, use the acronym alone.", "location": {"path": "_search-plugins/ubi/ubi_dashboard_tutorial.md", "range": {"start": {"line": 74, "column": 3}}}, "severity": "WARNING"}

Check warning on line 74 in _search-plugins/ubi/ubi_dashboard_tutorial.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/ubi_dashboard_tutorial.md#L74

[OpenSearch.AcronymParentheses] 'UBI': Spell out acronyms the first time that you use them on a page and follow them with the acronym in parentheses. Subsequently, use the acronym alone.
Raw output
{"message": "[OpenSearch.AcronymParentheses] 'UBI': Spell out acronyms the first time that you use them on a page and follow them with the acronym in parentheses. Subsequently, use the acronym alone.", "location": {"path": "_search-plugins/ubi/ubi_dashboard_tutorial.md", "range": {"start": {"line": 74, "column": 57}}}, "severity": "WARNING"}

You now have a basic dashboard that lets you look at the data. In the next Katas we'll focus on some typical ecommerce driven scenarios.
You now have a basic dashboard that lets you look at the data. In the next katas we'll focus on some typical ecommerce driven scenarios.

Check failure on line 76 in _search-plugins/ubi/ubi_dashboard_tutorial.md

View workflow job for this annotation

GitHub Actions / vale

[vale] _search-plugins/ubi/ubi_dashboard_tutorial.md#L76

[OpenSearch.Spelling] Error: katas. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.
Raw output
{"message": "[OpenSearch.Spelling] Error: katas. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.", "location": {"path": "_search-plugins/ubi/ubi_dashboard_tutorial.md", "range": {"start": {"line": 76, "column": 76}}}, "severity": "ERROR"}

0 comments on commit 84f9395

Please sign in to comment.