recombee_api_client 5.1.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/recombee_api_client/api/add_bookmark.rb +26 -26
- data/lib/recombee_api_client/api/add_cart_addition.rb +28 -28
- data/lib/recombee_api_client/api/add_detail_view.rb +32 -28
- data/lib/recombee_api_client/api/add_item.rb +15 -18
- data/lib/recombee_api_client/api/add_item_property.rb +34 -35
- data/lib/recombee_api_client/api/add_manual_reql_segment.rb +26 -27
- data/lib/recombee_api_client/api/add_purchase.rb +29 -29
- data/lib/recombee_api_client/api/add_rating.rb +27 -27
- data/lib/recombee_api_client/api/add_search_synonym.rb +29 -30
- data/lib/recombee_api_client/api/add_series.rb +20 -21
- data/lib/recombee_api_client/api/add_user.rb +14 -17
- data/lib/recombee_api_client/api/add_user_property.rb +30 -31
- data/lib/recombee_api_client/api/batch.rb +12 -16
- data/lib/recombee_api_client/api/composite_recommendation.rb +132 -0
- data/lib/recombee_api_client/api/create_auto_reql_segmentation.rb +29 -30
- data/lib/recombee_api_client/api/create_manual_reql_segmentation.rb +27 -28
- data/lib/recombee_api_client/api/create_property_based_segmentation.rb +30 -31
- data/lib/recombee_api_client/api/delete_all_search_synonyms.rb +15 -19
- data/lib/recombee_api_client/api/delete_bookmark.rb +21 -22
- data/lib/recombee_api_client/api/delete_cart_addition.rb +21 -22
- data/lib/recombee_api_client/api/delete_detail_view.rb +21 -22
- data/lib/recombee_api_client/api/delete_item.rb +16 -19
- data/lib/recombee_api_client/api/delete_item_property.rb +15 -18
- data/lib/recombee_api_client/api/delete_manual_reql_segment.rb +16 -19
- data/lib/recombee_api_client/api/delete_more_items.rb +18 -19
- data/lib/recombee_api_client/api/delete_purchase.rb +21 -22
- data/lib/recombee_api_client/api/delete_rating.rb +21 -22
- data/lib/recombee_api_client/api/delete_search_synonym.rb +15 -18
- data/lib/recombee_api_client/api/delete_segmentation.rb +15 -18
- data/lib/recombee_api_client/api/delete_series.rb +21 -22
- data/lib/recombee_api_client/api/delete_user.rb +15 -18
- data/lib/recombee_api_client/api/delete_user_property.rb +15 -18
- data/lib/recombee_api_client/api/delete_view_portion.rb +21 -22
- data/lib/recombee_api_client/api/get_item_property_info.rb +14 -17
- data/lib/recombee_api_client/api/get_item_values.rb +15 -18
- data/lib/recombee_api_client/api/get_segmentation.rb +15 -18
- data/lib/recombee_api_client/api/get_user_property_info.rb +15 -18
- data/lib/recombee_api_client/api/get_user_values.rb +15 -18
- data/lib/recombee_api_client/api/insert_to_series.rb +23 -24
- data/lib/recombee_api_client/api/list_item_bookmarks.rb +16 -19
- data/lib/recombee_api_client/api/list_item_cart_additions.rb +16 -19
- data/lib/recombee_api_client/api/list_item_detail_views.rb +16 -19
- data/lib/recombee_api_client/api/list_item_properties.rb +15 -19
- data/lib/recombee_api_client/api/list_item_purchases.rb +16 -19
- data/lib/recombee_api_client/api/list_item_ratings.rb +16 -19
- data/lib/recombee_api_client/api/list_item_view_portions.rb +16 -19
- data/lib/recombee_api_client/api/list_items.rb +62 -62
- data/lib/recombee_api_client/api/list_scenarios.rb +15 -19
- data/lib/recombee_api_client/api/list_search_synonyms.rb +20 -21
- data/lib/recombee_api_client/api/list_segmentations.rb +16 -17
- data/lib/recombee_api_client/api/list_series.rb +15 -19
- data/lib/recombee_api_client/api/list_series_items.rb +15 -18
- data/lib/recombee_api_client/api/list_user_bookmarks.rb +15 -18
- data/lib/recombee_api_client/api/list_user_cart_additions.rb +15 -18
- data/lib/recombee_api_client/api/list_user_detail_views.rb +15 -18
- data/lib/recombee_api_client/api/list_user_properties.rb +15 -19
- data/lib/recombee_api_client/api/list_user_purchases.rb +15 -18
- data/lib/recombee_api_client/api/list_user_ratings.rb +15 -18
- data/lib/recombee_api_client/api/list_user_view_portions.rb +15 -18
- data/lib/recombee_api_client/api/list_users.rb +56 -56
- data/lib/recombee_api_client/api/merge_users.rb +24 -25
- data/lib/recombee_api_client/api/recommend_item_segments_to_item.rb +69 -68
- data/lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb +70 -69
- data/lib/recombee_api_client/api/recommend_item_segments_to_user.rb +51 -50
- data/lib/recombee_api_client/api/recommend_items_to_item.rb +185 -139
- data/lib/recombee_api_client/api/recommend_items_to_item_segment.rb +181 -138
- data/lib/recombee_api_client/api/recommend_items_to_user.rb +165 -122
- data/lib/recombee_api_client/api/recommend_next_items.rb +24 -25
- data/lib/recombee_api_client/api/recommend_users_to_item.rb +151 -105
- data/lib/recombee_api_client/api/recommend_users_to_user.rb +154 -111
- data/lib/recombee_api_client/api/remove_from_series.rb +17 -18
- data/lib/recombee_api_client/api/request.rb +1 -1
- data/lib/recombee_api_client/api/reset_database.rb +15 -19
- data/lib/recombee_api_client/api/search_item_segments.rb +52 -51
- data/lib/recombee_api_client/api/search_items.rb +157 -114
- data/lib/recombee_api_client/api/set_item_values.rb +28 -29
- data/lib/recombee_api_client/api/set_user_values.rb +21 -22
- data/lib/recombee_api_client/api/set_values.rb +28 -28
- data/lib/recombee_api_client/api/set_view_portion.rb +37 -30
- data/lib/recombee_api_client/api/update_auto_reql_segmentation.rb +26 -27
- data/lib/recombee_api_client/api/update_manual_reql_segment.rb +25 -26
- data/lib/recombee_api_client/api/update_manual_reql_segmentation.rb +24 -25
- data/lib/recombee_api_client/api/update_more_items.rb +19 -20
- data/lib/recombee_api_client/api/update_property_based_segmentation.rb +26 -27
- data/lib/recombee_api_client/errors.rb +2 -5
- data/lib/recombee_api_client/inputs/composite_recommendation_stage_parameters.rb +240 -0
- data/lib/recombee_api_client/inputs/input.rb +9 -0
- data/lib/recombee_api_client/inputs/logic.rb +45 -0
- data/lib/recombee_api_client/utils/hash_normalizer.rb +21 -0
- data/lib/recombee_api_client/version.rb +1 -1
- data/lib/recombee_api_client.rb +40 -35
- data/recombee_api_client.gemspec +2 -3
- metadata +14 -10
- data/lib/recombee_api_client/api/hash_normalizer.rb +0 -21
|
@@ -5,20 +5,19 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Removes an existing series item from the series
|
|
10
|
+
# Removes an existing series item from the series.#
|
|
11
11
|
class RemoveFromSeries < ApiRequest
|
|
12
12
|
attr_reader :series_id, :item_type, :item_id
|
|
13
|
-
attr_accessor :timeout
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#
|
|
13
|
+
attr_accessor :timeout, :ensure_https
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# * *Required arguments*
|
|
17
|
+
# - +series_id+ -> ID of the series from which a series item is to be removed.
|
|
18
|
+
# - +item_type+ -> Type of the item to be removed.
|
|
19
|
+
# - +item_id+ -> ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`.
|
|
20
|
+
#
|
|
22
21
|
def initialize(series_id, item_type, item_id)
|
|
23
22
|
@series_id = series_id
|
|
24
23
|
@item_type = item_type
|
|
@@ -26,27 +25,27 @@ module RecombeeApiClient
|
|
|
26
25
|
@timeout = 3000
|
|
27
26
|
@ensure_https = false
|
|
28
27
|
end
|
|
29
|
-
|
|
28
|
+
|
|
30
29
|
# HTTP method
|
|
31
30
|
def method
|
|
32
31
|
:delete
|
|
33
32
|
end
|
|
34
|
-
|
|
33
|
+
|
|
35
34
|
# Values of body parameters as a Hash
|
|
36
35
|
def body_parameters
|
|
37
|
-
p =
|
|
36
|
+
p = {}
|
|
38
37
|
p['itemType'] = @item_type
|
|
39
38
|
p['itemId'] = @item_id
|
|
39
|
+
|
|
40
40
|
p
|
|
41
41
|
end
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
# Values of query parameters as a Hash.
|
|
44
44
|
# name of parameter => value of the parameter
|
|
45
45
|
def query_parameters
|
|
46
|
-
|
|
47
|
-
params
|
|
46
|
+
{}
|
|
48
47
|
end
|
|
49
|
-
|
|
48
|
+
|
|
50
49
|
# Relative path to the endpoint
|
|
51
50
|
def path
|
|
52
51
|
"/{databaseId}/series/#{@series_id}/items/"
|
|
@@ -5,43 +5,39 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Completely erases all your data, including items, item properties, series, user database, purchases, ratings, detail views, and bookmarks. Make sure the request is never executed in the production environment! Resetting your database is irreversible.
|
|
10
|
+
# Completely erases all your data, including items, item properties, series, user database, purchases, ratings, detail views, and bookmarks. Make sure the request is never executed in the production environment! Resetting your database is irreversible.
|
|
11
11
|
#
|
|
12
12
|
class ResetDatabase < ApiRequest
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def initialize()
|
|
20
|
-
@timeout = 100000
|
|
13
|
+
attr_accessor :timeout, :ensure_https
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
#
|
|
17
|
+
def initialize
|
|
18
|
+
@timeout = 100_000
|
|
21
19
|
@ensure_https = false
|
|
22
20
|
end
|
|
23
|
-
|
|
21
|
+
|
|
24
22
|
# HTTP method
|
|
25
23
|
def method
|
|
26
24
|
:delete
|
|
27
25
|
end
|
|
28
|
-
|
|
26
|
+
|
|
29
27
|
# Values of body parameters as a Hash
|
|
30
28
|
def body_parameters
|
|
31
|
-
|
|
32
|
-
p
|
|
29
|
+
{}
|
|
33
30
|
end
|
|
34
|
-
|
|
31
|
+
|
|
35
32
|
# Values of query parameters as a Hash.
|
|
36
33
|
# name of parameter => value of the parameter
|
|
37
34
|
def query_parameters
|
|
38
|
-
|
|
39
|
-
params
|
|
35
|
+
{}
|
|
40
36
|
end
|
|
41
|
-
|
|
37
|
+
|
|
42
38
|
# Relative path to the endpoint
|
|
43
39
|
def path
|
|
44
|
-
|
|
40
|
+
'/{databaseId}/'
|
|
45
41
|
end
|
|
46
42
|
end
|
|
47
43
|
end
|
|
@@ -5,64 +5,64 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Full-text personalized search that returns Segments from a Segmentation. The results are based on the provided `searchQuery` and also on the user's past interactions (purchases, ratings, etc.).
|
|
10
|
+
# Full-text personalized search that returns Segments from a Segmentation. The results are based on the provided `searchQuery` and also on the user's past interactions (purchases, ratings, etc.).
|
|
11
11
|
#
|
|
12
|
-
#Based on the used Segmentation, this endpoint can be used for example for:
|
|
12
|
+
# Based on the used Segmentation, this endpoint can be used for example for:
|
|
13
13
|
#
|
|
14
14
|
# - Searching within categories or brands
|
|
15
15
|
# - Searching within genres or artists
|
|
16
16
|
#
|
|
17
|
-
#For example if the user is searching for "iPhone" this endpoint can return "cell phones" category.
|
|
17
|
+
# For example if the user is searching for "iPhone" this endpoint can return "cell phones" category.
|
|
18
18
|
#
|
|
19
|
-
#You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
|
|
19
|
+
# You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
|
|
20
20
|
#
|
|
21
|
-
#The returned segments are sorted by relevance (first segment being the most relevant).
|
|
21
|
+
# The returned segments are sorted by relevance (first segment being the most relevant).
|
|
22
22
|
#
|
|
23
|
-
#It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
|
23
|
+
# It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
|
24
24
|
#
|
|
25
25
|
class SearchItemSegments < ApiRequest
|
|
26
|
-
attr_reader :user_id, :search_query, :count, :scenario, :cascade_create, :filter, :booster, :logic,
|
|
27
|
-
|
|
28
|
-
attr_accessor :ensure_https
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
26
|
+
attr_reader :user_id, :search_query, :count, :scenario, :cascade_create, :filter, :booster, :logic,
|
|
27
|
+
:expert_settings, :return_ab_group
|
|
28
|
+
attr_accessor :timeout, :ensure_https
|
|
29
|
+
|
|
30
|
+
##
|
|
31
|
+
# * *Required arguments*
|
|
32
|
+
# - +user_id+ -> ID of the user for whom personalized search will be performed.
|
|
33
|
+
# - +search_query+ -> Search query provided by the user. It is used for the full-text search.
|
|
34
|
+
# - +count+ -> Number of segments to be returned (N for the top-N results).
|
|
35
|
+
#
|
|
36
|
+
# * *Optional arguments (given as hash optional)*
|
|
37
|
+
# - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
|
|
38
|
+
#
|
|
39
|
+
# You can set various settings to the [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.
|
|
40
|
+
#
|
|
41
|
+
# The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.
|
|
42
|
+
#
|
|
43
|
+
# - +cascadeCreate+ -> If the user does not exist in the database, returns a list of non-personalized recommendations 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.
|
|
44
|
+
#
|
|
45
|
+
# - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
|
|
46
|
+
#
|
|
47
|
+
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
|
|
48
|
+
#
|
|
49
|
+
# - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
|
|
50
|
+
# See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
|
|
51
|
+
#
|
|
52
|
+
# The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
|
|
53
|
+
#
|
|
54
|
+
# Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
55
|
+
#
|
|
56
|
+
# - +expertSettings+ -> Dictionary of custom options.
|
|
57
|
+
#
|
|
58
|
+
# - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
|
|
59
|
+
#
|
|
60
|
+
#
|
|
61
61
|
def initialize(user_id, search_query, count, optional = {})
|
|
62
62
|
@user_id = user_id
|
|
63
63
|
@search_query = search_query
|
|
64
64
|
@count = count
|
|
65
|
-
optional =
|
|
65
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
66
66
|
@scenario = optional['scenario']
|
|
67
67
|
@cascade_create = optional['cascadeCreate']
|
|
68
68
|
@filter = optional['filter']
|
|
@@ -74,18 +74,19 @@ module RecombeeApiClient
|
|
|
74
74
|
@timeout = 3000
|
|
75
75
|
@ensure_https = false
|
|
76
76
|
@optional.each do |par, _|
|
|
77
|
-
|
|
77
|
+
raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate filter booster logic
|
|
78
|
+
expertSettings returnAbGroup].include? par
|
|
78
79
|
end
|
|
79
80
|
end
|
|
80
|
-
|
|
81
|
+
|
|
81
82
|
# HTTP method
|
|
82
83
|
def method
|
|
83
84
|
:post
|
|
84
85
|
end
|
|
85
|
-
|
|
86
|
+
|
|
86
87
|
# Values of body parameters as a Hash
|
|
87
88
|
def body_parameters
|
|
88
|
-
p =
|
|
89
|
+
p = {}
|
|
89
90
|
p['searchQuery'] = @search_query
|
|
90
91
|
p['count'] = @count
|
|
91
92
|
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
|
|
@@ -95,16 +96,16 @@ module RecombeeApiClient
|
|
|
95
96
|
p['logic'] = @optional['logic'] if @optional.include? 'logic'
|
|
96
97
|
p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
|
|
97
98
|
p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
|
|
99
|
+
|
|
98
100
|
p
|
|
99
101
|
end
|
|
100
|
-
|
|
102
|
+
|
|
101
103
|
# Values of query parameters as a Hash.
|
|
102
104
|
# name of parameter => value of the parameter
|
|
103
105
|
def query_parameters
|
|
104
|
-
|
|
105
|
-
params
|
|
106
|
+
{}
|
|
106
107
|
end
|
|
107
|
-
|
|
108
|
+
|
|
108
109
|
# Relative path to the endpoint
|
|
109
110
|
def path
|
|
110
111
|
"/{databaseId}/search/users/#{@user_id}/item-segments/"
|
|
@@ -5,125 +5,165 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#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).
|
|
10
|
+
# 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).
|
|
11
11
|
#
|
|
12
|
-
#All the string and set item properties are indexed by the search engine.
|
|
12
|
+
# All the string and set item properties are indexed by the search engine.
|
|
13
13
|
#
|
|
14
|
-
#This endpoint should be used in a search box on 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 the current state of the query, or once after submitting the whole query.
|
|
14
|
+
# This endpoint should be used in a search box on 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 the current state of the query, or once after submitting the whole query.
|
|
15
15
|
#
|
|
16
|
-
#The returned items are sorted by relevance (the first item being the most relevant).
|
|
16
|
+
# The returned items are sorted by relevance (the first item being the most relevant).
|
|
17
17
|
#
|
|
18
|
-
#Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
|
|
18
|
+
# Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
|
|
19
19
|
#
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
# - Let Recombee know that this search was successful (e.g., user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui#reported-metrics).
|
|
21
|
+
# - Get subsequent search results when the user scrolls down or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api#recommend-next-items).
|
|
22
22
|
#
|
|
23
|
-
#It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters.
|
|
23
|
+
# It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters.
|
|
24
24
|
#
|
|
25
25
|
class SearchItems < ApiRequest
|
|
26
|
-
attr_reader :user_id, :search_query, :count, :scenario, :cascade_create, :return_properties, :included_properties,
|
|
27
|
-
|
|
28
|
-
attr_accessor :ensure_https
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
26
|
+
attr_reader :user_id, :search_query, :count, :scenario, :cascade_create, :return_properties, :included_properties,
|
|
27
|
+
:filter, :booster, :logic, :reql_expressions, :expert_settings, :return_ab_group
|
|
28
|
+
attr_accessor :timeout, :ensure_https
|
|
29
|
+
|
|
30
|
+
##
|
|
31
|
+
# * *Required arguments*
|
|
32
|
+
# - +user_id+ -> ID of the user for whom personalized search will be performed.
|
|
33
|
+
# - +search_query+ -> Search query provided by the user. It is used for the full-text search.
|
|
34
|
+
# - +count+ -> Number of items to be returned (N for the top-N results).
|
|
35
|
+
#
|
|
36
|
+
# * *Optional arguments (given as hash optional)*
|
|
37
|
+
# - +scenario+ -> Scenario defines a particular search field in your user interface.
|
|
38
|
+
#
|
|
39
|
+
# You can set various settings to the [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each field performs.
|
|
40
|
+
#
|
|
41
|
+
# The AI that optimizes models to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
|
|
42
|
+
#
|
|
43
|
+
# - +cascadeCreate+ -> 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.
|
|
44
|
+
# - +returnProperties+ -> 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 to easily display the recommended items to the user.
|
|
45
|
+
#
|
|
46
|
+
# Example response:
|
|
47
|
+
# ```json
|
|
48
|
+
# {
|
|
49
|
+
# "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
|
|
50
|
+
# "recomms":
|
|
51
|
+
# [
|
|
52
|
+
# {
|
|
53
|
+
# "id": "tv-178",
|
|
54
|
+
# "values": {
|
|
55
|
+
# "description": "4K TV with 3D feature",
|
|
56
|
+
# "categories": ["Electronics", "Televisions"],
|
|
57
|
+
# "price": 342,
|
|
58
|
+
# "url": "myshop.com/tv-178"
|
|
59
|
+
# }
|
|
60
|
+
# },
|
|
61
|
+
# {
|
|
62
|
+
# "id": "mixer-42",
|
|
63
|
+
# "values": {
|
|
64
|
+
# "description": "Stainless Steel Mixer",
|
|
65
|
+
# "categories": ["Home & Kitchen"],
|
|
66
|
+
# "price": 39,
|
|
67
|
+
# "url": "myshop.com/mixer-42"
|
|
68
|
+
# }
|
|
69
|
+
# }
|
|
70
|
+
# ],
|
|
71
|
+
# "numberNextRecommsCalls": 0
|
|
72
|
+
# }
|
|
73
|
+
# ```
|
|
74
|
+
#
|
|
75
|
+
# - +includedProperties+ -> Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
|
|
76
|
+
#
|
|
77
|
+
# Example response for `includedProperties=description,price`:
|
|
78
|
+
# ```json
|
|
79
|
+
# {
|
|
80
|
+
# "recommId": "a86ee8d5-cd8e-46d1-886c-8b3771d0520b",
|
|
81
|
+
# "recomms":
|
|
82
|
+
# [
|
|
83
|
+
# {
|
|
84
|
+
# "id": "tv-178",
|
|
85
|
+
# "values": {
|
|
86
|
+
# "description": "4K TV with 3D feature",
|
|
87
|
+
# "price": 342
|
|
88
|
+
# }
|
|
89
|
+
# },
|
|
90
|
+
# {
|
|
91
|
+
# "id": "mixer-42",
|
|
92
|
+
# "values": {
|
|
93
|
+
# "description": "Stainless Steel Mixer",
|
|
94
|
+
# "price": 39
|
|
95
|
+
# }
|
|
96
|
+
# }
|
|
97
|
+
# ],
|
|
98
|
+
# "numberNextRecommsCalls": 0
|
|
99
|
+
# }
|
|
100
|
+
# ```
|
|
101
|
+
#
|
|
102
|
+
# - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter recommended items based on the values of their attributes.
|
|
103
|
+
#
|
|
104
|
+
# Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
105
|
+
#
|
|
106
|
+
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes.
|
|
107
|
+
#
|
|
108
|
+
# Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
109
|
+
#
|
|
110
|
+
# - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
|
|
111
|
+
# See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
|
|
112
|
+
#
|
|
113
|
+
# The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
|
|
114
|
+
#
|
|
115
|
+
# Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
116
|
+
#
|
|
117
|
+
# - +reqlExpressions+ -> A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended item.
|
|
118
|
+
# This can be used to compute additional properties of the recommended items that are not stored in the database.
|
|
119
|
+
#
|
|
120
|
+
# The keys are the names of the expressions, and the values are the actual ReQL expressions.
|
|
121
|
+
#
|
|
122
|
+
# Example request:
|
|
123
|
+
# ```json
|
|
124
|
+
# {
|
|
125
|
+
# "reqlExpressions": {
|
|
126
|
+
# "isInUsersCity": "context_user[\"city\"] in 'cities'",
|
|
127
|
+
# "distanceToUser": "earth_distance('location', context_user[\"location\"])"
|
|
128
|
+
# }
|
|
129
|
+
# }
|
|
130
|
+
# ```
|
|
131
|
+
#
|
|
132
|
+
# Example response:
|
|
133
|
+
# ```json
|
|
134
|
+
# {
|
|
135
|
+
# "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
|
|
136
|
+
# "recomms":
|
|
137
|
+
# [
|
|
138
|
+
# {
|
|
139
|
+
# "id": "restaurant-178",
|
|
140
|
+
# "reqlEvaluations": {
|
|
141
|
+
# "isInUsersCity": true,
|
|
142
|
+
# "distanceToUser": 5200.2
|
|
143
|
+
# }
|
|
144
|
+
# },
|
|
145
|
+
# {
|
|
146
|
+
# "id": "bar-42",
|
|
147
|
+
# "reqlEvaluations": {
|
|
148
|
+
# "isInUsersCity": false,
|
|
149
|
+
# "distanceToUser": 2516.0
|
|
150
|
+
# }
|
|
151
|
+
# }
|
|
152
|
+
# ],
|
|
153
|
+
# "numberNextRecommsCalls": 0
|
|
154
|
+
# }
|
|
155
|
+
# ```
|
|
156
|
+
#
|
|
157
|
+
# - +expertSettings+ -> Dictionary of custom options.
|
|
158
|
+
#
|
|
159
|
+
# - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
|
|
160
|
+
#
|
|
161
|
+
#
|
|
122
162
|
def initialize(user_id, search_query, count, optional = {})
|
|
123
163
|
@user_id = user_id
|
|
124
164
|
@search_query = search_query
|
|
125
165
|
@count = count
|
|
126
|
-
optional =
|
|
166
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
127
167
|
@scenario = optional['scenario']
|
|
128
168
|
@cascade_create = optional['cascadeCreate']
|
|
129
169
|
@return_properties = optional['returnProperties']
|
|
@@ -131,24 +171,26 @@ module RecombeeApiClient
|
|
|
131
171
|
@filter = optional['filter']
|
|
132
172
|
@booster = optional['booster']
|
|
133
173
|
@logic = optional['logic']
|
|
174
|
+
@reql_expressions = optional['reqlExpressions']
|
|
134
175
|
@expert_settings = optional['expertSettings']
|
|
135
176
|
@return_ab_group = optional['returnAbGroup']
|
|
136
177
|
@optional = optional
|
|
137
178
|
@timeout = 3000
|
|
138
179
|
@ensure_https = false
|
|
139
180
|
@optional.each do |par, _|
|
|
140
|
-
|
|
181
|
+
raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate returnProperties
|
|
182
|
+
includedProperties filter booster logic reqlExpressions expertSettings returnAbGroup].include? par
|
|
141
183
|
end
|
|
142
184
|
end
|
|
143
|
-
|
|
185
|
+
|
|
144
186
|
# HTTP method
|
|
145
187
|
def method
|
|
146
188
|
:post
|
|
147
189
|
end
|
|
148
|
-
|
|
190
|
+
|
|
149
191
|
# Values of body parameters as a Hash
|
|
150
192
|
def body_parameters
|
|
151
|
-
p =
|
|
193
|
+
p = {}
|
|
152
194
|
p['searchQuery'] = @search_query
|
|
153
195
|
p['count'] = @count
|
|
154
196
|
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
|
|
@@ -158,18 +200,19 @@ module RecombeeApiClient
|
|
|
158
200
|
p['filter'] = @optional['filter'] if @optional.include? 'filter'
|
|
159
201
|
p['booster'] = @optional['booster'] if @optional.include? 'booster'
|
|
160
202
|
p['logic'] = @optional['logic'] if @optional.include? 'logic'
|
|
203
|
+
p['reqlExpressions'] = @optional['reqlExpressions'] if @optional.include? 'reqlExpressions'
|
|
161
204
|
p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
|
|
162
205
|
p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
|
|
206
|
+
|
|
163
207
|
p
|
|
164
208
|
end
|
|
165
|
-
|
|
209
|
+
|
|
166
210
|
# Values of query parameters as a Hash.
|
|
167
211
|
# name of parameter => value of the parameter
|
|
168
212
|
def query_parameters
|
|
169
|
-
|
|
170
|
-
params
|
|
213
|
+
{}
|
|
171
214
|
end
|
|
172
|
-
|
|
215
|
+
|
|
173
216
|
# Relative path to the endpoint
|
|
174
217
|
def path
|
|
175
218
|
"/{databaseId}/search/users/#{@user_id}/items/"
|