Scenarios

Get Scenario

GET scenarios/<str:reco_type>/<str:name>/

Note

Authorized Roles: root, manager, backend

Return scenario [see Scenarios].

Response JSON Object
  • reranking (list-of-object) –

    Optional. List of reranking rules

    Inner fields:

    • property_name (string) – Item-property name

    • op (enum) – choices: [diversity] Reranking op

    • weight (float) – Weight to apply to reranking; must be positive; defaults to 1; values between 0 and 1.5 are recommended

    • options (object) – Op-specific options

  • filters (list-of-object) –

    Optional. List of filters

    Inner fields:

    • property_name (string) – Item-property name

    • op (enum) – choices: [eq, lt, lte, gt, gte, in, notempty, neq, notin] Filter Operator

    • value (any) – Filter Value

  • exclude_rated_items (bool) – Optional. Exclude already rated items from response.

  • algorithms (string) – Optional. [WORK IN PROGRESS] Algorithms whitelist, formatted as a single string of |-separated values

EXAMPLE RESPONSE
{
    "filters": [{"property_name": "year", "op": "GEQ", "value": 1988}],
    "reranking": [{"property_name": "genres", "op": "diversity", "weight": 0.25}],
    "exclude_rated_items": false
}

Errors:

  • NotFoundError with error name SCENARIO_NOT_FOUND if a scenario is missing

Create or Replace Scenario

PUT scenarios/<str:reco_type>/<str:name>/

Note

Authorized Roles: root, manager, backend

Create or replace a scenario [see Scenarios].

Request JSON Object
  • reranking (list-of-(string|object)) –

    Optional. List of reranking rules

    See Reranking Syntax for the syntax

    Inner fields:

    • property_name (string) – Item-property name

    • op (enum) – choices: [diversity] Reranking op

    • weight (float) – Weight to apply to reranking; must be positive; defaults to 1; values between 0 and 1.5 are recommended

    • options (object) – Op-specific options

  • filters (list-of-(string|object)) –

    Optional. List of filters

    The field value is incompatible with notempty. See Filter Syntax for the syntax.

    Inner fields:

    • property_name (string) – Item-property name

    • op (enum) – choices: [eq, lt, lte, gt, gte, in, notempty, neq, notin] Filter Operator

    • value (any) – Filter Value

  • exclude_rated_items (bool) – Optional. Exclude already rated items from response

  • algorithms (string) – Optional. [WORK IN PROGRESS] Algorithms whitelist, formatted as a single string of |-separated values

EXAMPLE QUERY BODY
{
    "filters": [
        {"property_name": "tags", "op": "EQ", "value": "pi"},
        {"property_name": "price", "op": "GEQ", "value": 3.14}
    ],
    "reranking": [
        {"property_name": "director", "op": "diversity", "weight": 0.8}
    ],
    "exclude_rated_items": true,
    "algorithms": "algo101|algo102"
}
Response JSON Object
  • warnings (list-of-string) – Warnings about the scenario

EXAMPLE RESPONSE
{
    "warnings": ["Missing property value `test`"]
}

Errors:

  • WrongData with error name WRONG_DATA_TYPE if any business rule is invalid

Delete A Scenario

DELETE scenarios/<str:reco_type>/<str:name>/

Note

Authorized Roles: root, manager, backend

Delete single scenario [see Scenarios].

Errors:

  • NotFoundError with error name SCENARIO_NOT_FOUND if named scenario is missing

Get All Scenarios

GET scenarios/

Note

Authorized Roles: root, manager, backend

Return all scenarios [see Scenarios].

Response JSON Object
  • scenarios (list-of-object) –

    Inner fields:

    • reranking (list-of-object) – List of reranking rules

      Inner fields:

      • property_name (string) – Item-property name

      • op (enum) – choices: [diversity] Reranking op

      • weight (float) – Weight to apply to reranking; must be positive; defaults to 1; values between 0 and 1.5 are recommended

      • options (object) – Op-specific options

    • filters (list-of-object) – List of filters

      Inner fields:

      • property_name (string) – Item-property name

      • op (enum) – choices: [eq, lt, lte, gt, gte, in, notempty, neq, notin] Filter Operator

      • value (any) – Filter Value

    • exclude_rated_items (bool) – Exclude already rated items from response.

    • algorithms (string) – [WORK IN PROGRESS] Algorithms whitelist, formatted as a single string of |-separated values

    • name (string) – [max-length: 64] Scenario Name

    • reco_type (enum) – choices: [item_to_items, profile_to_items, session_to_items] Type of recommendation a scenario applies to

EXAMPLE RESPONSE
{
    "scenarios": [
        "name": "scenario_101",
        "reco_type": "session_to_items",
        "filters": [{"property_name": "year", "op": "GEQ", "value": 1988}],
        "reranking": [{"property_name": "genres", "op": "diversity", "weight": 0.25}],
        "algorithms": "algo103|algo104",
        "exclude_rated_items": false
    ]
}

Get Default Scenario

GET scenarios-default/<str:reco_type>/

Note

Authorized Roles: root, manager, backend

Get default scenario [see Default Scenarios].

Response JSON Object
  • name (string) – [max-length: 64] Scenario Name

EXAMPLE RESPONSE
{
    "name": "scenario_109"
}
  • NotFoundError with error name SCENARIO_NOT_FOUND if there is no default scenario for this reco_type

Set Default Scenario

PATCH scenarios-default/<str:reco_type>/

Note

Authorized Roles: root, manager, backend

Set scenario as default [see Default Scenarios].

Request JSON Object
  • name (string) – [max-length: 64] Scenario Name

EXAMPLE QUERY BODY
{
    "name": "scenario_107"
}

Errors:

  • NotFoundError with error name SCENARIO_NOT_FOUND if named scenario is missing

Unset Default Scenario

DELETE scenarios-default/<str:reco_type>/

Note

Authorized Roles: root, manager, backend

Unset a scenario from being by default [see Default Scenarios].