SearchItems extends Request
Full-text personalized search. The results are based on the provided `searchQuery` and also on the user's past interactions (purchases, ratings, etc.) with the items (items more suitable for the user are preferred in the results).
All the string and set item properties are indexed by the search engine.
This endpoint should be used in a search box at your website/app. It can be called multiple times as the user is typing the query in order to get the most viable suggestions based on current state of the query, or once after submitting the whole query.
The returned items are sorted by relevance (first item being the most relevant).
Besides the recommended items, also a unique recommId
is returned in the response. It can be used to:
- Let Recombee know that this search was successful (e.g. user clicked one of the recommended items). See Reported metrics.
- Get subsequent search results when the user scrolls down or goes to the next page. See Recommend Next Items. It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
Table of Contents
- $booster : string
- $cascade_create : bool
- $count : int
- $ensure_https : bool
- $expert_settings : array<string|int, mixed>
- $filter : string
- $included_properties : array<string|int, mixed>
- $logic : string|array<string|int, mixed>
- $optional : array<string|int, mixed>
- $return_ab_group : bool
- $return_properties : bool
- $scenario : string
- $search_query : string
- $timeout : int
- $user_id : string
- __construct() : mixed
- Construct the request
- getBodyParameters() : array<string|int, mixed>
- Get body parameters
- getEnsureHttps() : bool
- Returns true if HTTPS must be chosen over HTTP for this request
- getMethod() : static
- Get used HTTP method
- getPath() : string
- Get URI to the endpoint
- getQueryParameters() : array<string|int, mixed>
- Get query parameters
- getTimeout() : int
- Get request timeout
- setEnsureHttps() : mixed
- Sets if HTTPS must be chosen over HTTP for this request
- setTimeout() : mixed
- Sets request timeout
Properties
$booster
protected
string
$booster
$cascade_create
protected
bool
$cascade_create
$count
protected
int
$count
$ensure_https
protected
bool
$ensure_https
$expert_settings
protected
array<string|int, mixed>
$expert_settings
$filter
protected
string
$filter
$included_properties
protected
array<string|int, mixed>
$included_properties
$logic
protected
string|array<string|int, mixed>
$logic
$optional
protected
array<string|int, mixed>
$optional
$return_ab_group
protected
bool
$return_ab_group
$return_properties
protected
bool
$return_properties
$scenario
protected
string
$scenario
$search_query
protected
string
$search_query
$timeout
protected
int
$timeout
$user_id
protected
string
$user_id
Methods
__construct()
Construct the request
public
__construct(string $user_id, string $search_query, int $count[, array<string|int, mixed> $optional = array() ]) : mixed
Parameters
- $user_id : string
-
ID of the user for whom personalized search will be performed.
- $search_query : string
-
Search query provided by the user. It is used for the full-text search.
- $count : int
-
Number of items to be returned (N for the top-N results).
- $optional : array<string|int, mixed> = array()
-
Optional parameters given as an array containing pairs name of the parameter => value
- Allowed parameters:
-
scenario
- Type: string
- Description: Scenario defines a particular search field in your user interface. You can set various settings to the scenario in the Admin UI. You can also see performance of each scenario in the Admin UI separately, so you can check how well each field performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
-
cascadeCreate
- Type: bool
- Description: If the user does not exist in the database, returns a list of non-personalized search results and creates the user in the database. This allows for example rotations in the following recommendations for that user, as the user will be already known to the system.
-
returnProperties
- Type: bool
- Description: With
returnProperties=true
, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user. Example response:
-
scenario
{ "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837", "recomms": [ { "id": "tv-178", "values": { "description": "4K TV with 3D feature", "categories": ["Electronics", "Televisions"], "price": 342, "url": "myshop.com/tv-178" } }, { "id": "mixer-42", "values": { "description": "Stainless Steel Mixer", "categories": ["Home & Kitchen"], "price": 39, "url": "myshop.com/mixer-42" } } ], "numberNextRecommsCalls": 0 }
- *includedProperties* - Type: array - Description: Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
Example response for
includedProperties=description,price
:{ "recommId": "a86ee8d5-cd8e-46d1-886c-8b3771d0520b", "recomms": [ { "id": "tv-178", "values": { "description": "4K TV with 3D feature", "price": 342 } }, { "id": "mixer-42", "values": { "description": "Stainless Steel Mixer", "price": 39 } } ], "numberNextRecommsCalls": 0 }
- *filter* - Type: string - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
Filters can be also assigned to a scenario in the Admin UI. - booster - Type: string - Description: Number-returning ReQL expression which allows you to boost recommendation rate of some items based on the values of their attributes. Boosters can be also assigned to a scenario in the Admin UI. - logic - Type: string|array - Description: Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for list of available logics and other details. The difference between
logic
andscenario
is thatlogic
specifies mainly behavior, whilescenario
specifies the place where recommendations are shown to the users. Logic can be also set to a scenario in the Admin UI. - expertSettings - Type: array - Description: Dictionary of custom options. - returnAbGroup - Type: bool - Description: If there is a custom AB-testing running, return name of group to which the request belongs. - Allowed parameters:
Tags
Return values
mixed —getBodyParameters()
Get body parameters
public
getBodyParameters() : array<string|int, mixed>
Return values
array<string|int, mixed> —Values of body parameters (name of parameter => value of the parameter)
getEnsureHttps()
Returns true if HTTPS must be chosen over HTTP for this request
public
getEnsureHttps() : bool
Return values
bool —true if HTTPS must be chosen
getMethod()
Get used HTTP method
public
getMethod() : static
Return values
static —Used HTTP method
getPath()
Get URI to the endpoint
public
getPath() : string
Return values
string —URI to the endpoint
getQueryParameters()
Get query parameters
public
getQueryParameters() : array<string|int, mixed>
Return values
array<string|int, mixed> —Values of query parameters (name of parameter => value of the parameter)
getTimeout()
Get request timeout
public
getTimeout() : int
Return values
int —Request timeout in milliseconds
setEnsureHttps()
Sets if HTTPS must be chosen over HTTP for this request
public
setEnsureHttps(mixed $ensure_https) : mixed
Parameters
- $ensure_https : mixed
Return values
mixed —setTimeout()
Sets request timeout
public
setTimeout(mixed $timeout) : mixed
Parameters
- $timeout : mixed