Context
| Name | Description | Example |
|---|---|---|
| context_item | Retrieves property value of the item, that is currently viewed by the user. | |
| context_user | Retrieves property value of the user, that is about to obtain the recommendations. | |
| context_segment | Retrieves the Segment on which the recommendations are based |
Context Item Function
Context item function is used in Recommend Items to Item and Recommend Item Segments to Item for retrieving property values of the item, that is currently viewed by the user.
Definition
| Key | Type | Meaning |
|---|---|---|
| property_name | string | Name of property to be retrieved. If property of this name does not exist, an error is produced. |
(Note that Context item function is a bit special function – it takes no arguments and returns a map name of property -> value representing the context item. property_name placed in square brackets is the key to this map.)
Examples
Consider following sample items.
name String | price Number | category String |
|---|---|---|
| "television-42" | 369 | "television" |
| "television-49" | 449 | "television" |
| "remote-control-13" | 25 | remote-control |
Example 1
Suppose that the user is currently viewing television-42. Then the following expression returns 369, because that is the price of the context item.
Example 2 - Up-Sell
Suppose that the user is currently viewing television-42. You can recommend him products from the same category with higher price. The filter would look like this:
Considering the sample items above, only television-49 will pass the filter.
If you don’t want to be so restrictive about the cheaper products, you shall use booster instead of filter and boost the products with higher price. The booster could look like this:
Context User Function
Context user function is used for retrieving property values of the user that the recommendations are for.
Definition
| Key | Type | Meaning |
|---|---|---|
| property_name | string | Name of property to be retrieved. If property of this name does not exist, an error is produced. |
(Note that Context user function is a bit special function – it takes no arguments and returns a map name of property -> value representing the context user. property_name placed in square brackets is the key to this map.)
Example
Consider following sample users, which have specified languages they understand:
userId String | languages Set |
|---|---|
| "user-27" | ["EN"] |
| "user-29" | ["EN", "FR"] |
And sample items, which are some movies:
itemId String | language String |
|---|---|
| "Pulp Fiction" | "EN" |
| "Le fabuleux destin d Amelie Poulain" | "FR" |
| "Fight Club" | "EN" |
| "Kolja" | "CS" |
Suppose that I want to recommend movies to users, but only movies that the users can understand. I can use the following filter:
For user-27 (which can speak only english) Pulp Fiction or Fight Club can be recommended.
For user-29 (which can speak english and french) Pulp Fiction, Fight Club or Le fabuleux destin d Amelie Poulain can be recommended.
Context Segment Function
Context Segment function is used in Recommend Item Segments to Item Segment for retrieving the Item Segment to which is being recommended.
Definition
| Key | Type | Meaning |
|---|---|---|
| property_name | string | Name of property to be retrieved. Currently only |