recombee_api_client 5.1.0 → 6.1.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 +108 -68
- data/lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb +109 -69
- data/lib/recombee_api_client/api/recommend_item_segments_to_user.rb +90 -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 +91 -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,81 +5,118 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Recommends Segments from a result [Segmentation](https://docs.recombee.com/segmentations) that are the most relevant to a particular Segment from a context Segmentation.
|
|
10
|
+
# Recommends Segments from a result [Segmentation](https://docs.recombee.com/segmentations) that are the most relevant to a particular Segment from a context Segmentation.
|
|
11
11
|
#
|
|
12
|
-
#Based on the used Segmentations, this endpoint can be used for example for:
|
|
12
|
+
# Based on the used Segmentations, this endpoint can be used for example for:
|
|
13
13
|
#
|
|
14
14
|
# - Recommending the related brands to particular brand
|
|
15
15
|
# - Recommending the related brands to particular category
|
|
16
16
|
# - Recommending the related artists to a particular genre (assuming songs are the Items)
|
|
17
17
|
#
|
|
18
|
-
#You need to set the used context and result Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
|
|
18
|
+
# You need to set the used context and result Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
|
|
19
19
|
#
|
|
20
|
-
#The returned segments are sorted by relevance (first segment being the most relevant).
|
|
20
|
+
# The returned segments are sorted by relevance (first segment being the most relevant).
|
|
21
21
|
#
|
|
22
|
-
#It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
|
22
|
+
# 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
23
|
#
|
|
24
24
|
class RecommendItemSegmentsToItemSegment < ApiRequest
|
|
25
|
-
attr_reader :context_segment_id, :target_user_id, :count, :scenario, :cascade_create, :filter, :booster, :logic,
|
|
26
|
-
|
|
27
|
-
attr_accessor :ensure_https
|
|
28
|
-
|
|
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
|
-
|
|
25
|
+
attr_reader :context_segment_id, :target_user_id, :count, :scenario, :cascade_create, :filter, :booster, :logic,
|
|
26
|
+
:expert_settings, :return_ab_group, :reql_expressions
|
|
27
|
+
attr_accessor :timeout, :ensure_https
|
|
28
|
+
|
|
29
|
+
##
|
|
30
|
+
# * *Required arguments*
|
|
31
|
+
# - +context_segment_id+ -> ID of the segment from `contextSegmentationId` for which the recommendations are to be generated.
|
|
32
|
+
# - +target_user_id+ -> ID of the user who will see the recommendations.
|
|
33
|
+
#
|
|
34
|
+
# Specifying the *targetUserId* is beneficial because:
|
|
35
|
+
#
|
|
36
|
+
# * It makes the recommendations personalized
|
|
37
|
+
# * Allows the calculation of Actions and Conversions
|
|
38
|
+
# in the graphical user interface,
|
|
39
|
+
# as Recombee can pair the user who got recommendations
|
|
40
|
+
# and who afterward viewed/purchased an item.
|
|
41
|
+
#
|
|
42
|
+
# If you insist on not specifying the user, pass `null`
|
|
43
|
+
# (`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*.
|
|
44
|
+
# Do not create some special dummy user for getting recommendations,
|
|
45
|
+
# as it could mislead the recommendation models,
|
|
46
|
+
# and result in wrong recommendations.
|
|
47
|
+
#
|
|
48
|
+
# For anonymous/unregistered users, it is possible to use, for example, their session ID.
|
|
49
|
+
#
|
|
50
|
+
# - +count+ -> Number of item segments to be recommended (N for the top-N recommendation).
|
|
51
|
+
#
|
|
52
|
+
#
|
|
53
|
+
# * *Optional arguments (given as hash optional)*
|
|
54
|
+
# - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
|
|
55
|
+
#
|
|
56
|
+
# 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.
|
|
57
|
+
#
|
|
58
|
+
# 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.
|
|
59
|
+
#
|
|
60
|
+
# - +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.
|
|
61
|
+
#
|
|
62
|
+
# - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
|
|
63
|
+
#
|
|
64
|
+
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
|
|
65
|
+
#
|
|
66
|
+
# - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
|
|
67
|
+
# See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
|
|
68
|
+
#
|
|
69
|
+
# The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
|
|
70
|
+
#
|
|
71
|
+
# Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
72
|
+
#
|
|
73
|
+
# - +expertSettings+ -> Dictionary of custom options.
|
|
74
|
+
#
|
|
75
|
+
# - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
|
|
76
|
+
#
|
|
77
|
+
# - +reqlExpressions+ -> A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
|
|
78
|
+
# This can be used to compute additional properties of the recommended Item Segments.
|
|
79
|
+
#
|
|
80
|
+
# The keys are the names of the expressions, and the values are the actual ReQL expressions.
|
|
81
|
+
#
|
|
82
|
+
# Example request:
|
|
83
|
+
# ```json
|
|
84
|
+
# {
|
|
85
|
+
# "reqlExpressions": {
|
|
86
|
+
# "countItems": "size(segment_items(\"categories\", 'segmentId'))"
|
|
87
|
+
# }
|
|
88
|
+
# }
|
|
89
|
+
# ```
|
|
90
|
+
#
|
|
91
|
+
# Example response:
|
|
92
|
+
# ```json
|
|
93
|
+
# {
|
|
94
|
+
# "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
|
|
95
|
+
# "recomms":
|
|
96
|
+
# [
|
|
97
|
+
# {
|
|
98
|
+
# "id": "category-fantasy-books",
|
|
99
|
+
# "reqlEvaluations": {
|
|
100
|
+
# "countItems": 486
|
|
101
|
+
# }
|
|
102
|
+
# },
|
|
103
|
+
# {
|
|
104
|
+
# "id": "category-sci-fi-costumes",
|
|
105
|
+
# "reqlEvaluations": {
|
|
106
|
+
# "countItems": 19
|
|
107
|
+
# }
|
|
108
|
+
# }
|
|
109
|
+
# ],
|
|
110
|
+
# "numberNextRecommsCalls": 0
|
|
111
|
+
# }
|
|
112
|
+
# ```
|
|
113
|
+
#
|
|
114
|
+
#
|
|
78
115
|
def initialize(context_segment_id, target_user_id, count, optional = {})
|
|
79
116
|
@context_segment_id = context_segment_id
|
|
80
117
|
@target_user_id = target_user_id
|
|
81
118
|
@count = count
|
|
82
|
-
optional =
|
|
119
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
83
120
|
@scenario = optional['scenario']
|
|
84
121
|
@cascade_create = optional['cascadeCreate']
|
|
85
122
|
@filter = optional['filter']
|
|
@@ -87,22 +124,24 @@ module RecombeeApiClient
|
|
|
87
124
|
@logic = optional['logic']
|
|
88
125
|
@expert_settings = optional['expertSettings']
|
|
89
126
|
@return_ab_group = optional['returnAbGroup']
|
|
127
|
+
@reql_expressions = optional['reqlExpressions']
|
|
90
128
|
@optional = optional
|
|
91
129
|
@timeout = 3000
|
|
92
130
|
@ensure_https = false
|
|
93
131
|
@optional.each do |par, _|
|
|
94
|
-
|
|
132
|
+
raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate filter booster logic
|
|
133
|
+
expertSettings returnAbGroup reqlExpressions].include? par
|
|
95
134
|
end
|
|
96
135
|
end
|
|
97
|
-
|
|
136
|
+
|
|
98
137
|
# HTTP method
|
|
99
138
|
def method
|
|
100
139
|
:post
|
|
101
140
|
end
|
|
102
|
-
|
|
141
|
+
|
|
103
142
|
# Values of body parameters as a Hash
|
|
104
143
|
def body_parameters
|
|
105
|
-
p =
|
|
144
|
+
p = {}
|
|
106
145
|
p['contextSegmentId'] = @context_segment_id
|
|
107
146
|
p['targetUserId'] = @target_user_id
|
|
108
147
|
p['count'] = @count
|
|
@@ -113,19 +152,20 @@ module RecombeeApiClient
|
|
|
113
152
|
p['logic'] = @optional['logic'] if @optional.include? 'logic'
|
|
114
153
|
p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
|
|
115
154
|
p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
|
|
155
|
+
p['reqlExpressions'] = @optional['reqlExpressions'] if @optional.include? 'reqlExpressions'
|
|
156
|
+
|
|
116
157
|
p
|
|
117
158
|
end
|
|
118
|
-
|
|
159
|
+
|
|
119
160
|
# Values of query parameters as a Hash.
|
|
120
161
|
# name of parameter => value of the parameter
|
|
121
162
|
def query_parameters
|
|
122
|
-
|
|
123
|
-
params
|
|
163
|
+
{}
|
|
124
164
|
end
|
|
125
|
-
|
|
165
|
+
|
|
126
166
|
# Relative path to the endpoint
|
|
127
167
|
def path
|
|
128
|
-
|
|
168
|
+
'/{databaseId}/recomms/item-segments/item-segments/'
|
|
129
169
|
end
|
|
130
170
|
end
|
|
131
171
|
end
|
|
@@ -5,63 +5,100 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Recommends the top Segments from a [Segmentation](https://docs.recombee.com/segmentations) for a particular user, based on the user's past interactions.
|
|
10
|
+
# Recommends the top Segments from a [Segmentation](https://docs.recombee.com/segmentations) for a particular user, based on the user's past interactions.
|
|
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
|
# - Recommending the top categories for the user
|
|
15
15
|
# - Recommending the top genres for the user
|
|
16
16
|
# - Recommending the top brands for the user
|
|
17
17
|
# - Recommending the top artists for the user
|
|
18
18
|
#
|
|
19
|
-
#You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
|
|
19
|
+
# You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) 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 RecommendItemSegmentsToUser < ApiRequest
|
|
26
|
-
attr_reader :user_id, :count, :scenario, :cascade_create, :filter, :booster, :logic, :expert_settings,
|
|
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, :count, :scenario, :cascade_create, :filter, :booster, :logic, :expert_settings,
|
|
27
|
+
:return_ab_group, :reql_expressions
|
|
28
|
+
attr_accessor :timeout, :ensure_https
|
|
29
|
+
|
|
30
|
+
##
|
|
31
|
+
# * *Required arguments*
|
|
32
|
+
# - +user_id+ -> ID of the user for whom personalized recommendations are to be generated.
|
|
33
|
+
# - +count+ -> Number of item segments to be recommended (N for the top-N recommendation).
|
|
34
|
+
#
|
|
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
|
+
# - +reqlExpressions+ -> A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
|
|
61
|
+
# This can be used to compute additional properties of the recommended Item Segments.
|
|
62
|
+
#
|
|
63
|
+
# The keys are the names of the expressions, and the values are the actual ReQL expressions.
|
|
64
|
+
#
|
|
65
|
+
# Example request:
|
|
66
|
+
# ```json
|
|
67
|
+
# {
|
|
68
|
+
# "reqlExpressions": {
|
|
69
|
+
# "countItems": "size(segment_items(\"categories\", 'segmentId'))"
|
|
70
|
+
# }
|
|
71
|
+
# }
|
|
72
|
+
# ```
|
|
73
|
+
#
|
|
74
|
+
# Example response:
|
|
75
|
+
# ```json
|
|
76
|
+
# {
|
|
77
|
+
# "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
|
|
78
|
+
# "recomms":
|
|
79
|
+
# [
|
|
80
|
+
# {
|
|
81
|
+
# "id": "category-fantasy-books",
|
|
82
|
+
# "reqlEvaluations": {
|
|
83
|
+
# "countItems": 486
|
|
84
|
+
# }
|
|
85
|
+
# },
|
|
86
|
+
# {
|
|
87
|
+
# "id": "category-sci-fi-costumes",
|
|
88
|
+
# "reqlEvaluations": {
|
|
89
|
+
# "countItems": 19
|
|
90
|
+
# }
|
|
91
|
+
# }
|
|
92
|
+
# ],
|
|
93
|
+
# "numberNextRecommsCalls": 0
|
|
94
|
+
# }
|
|
95
|
+
# ```
|
|
96
|
+
#
|
|
97
|
+
#
|
|
61
98
|
def initialize(user_id, count, optional = {})
|
|
62
99
|
@user_id = user_id
|
|
63
100
|
@count = count
|
|
64
|
-
optional =
|
|
101
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
65
102
|
@scenario = optional['scenario']
|
|
66
103
|
@cascade_create = optional['cascadeCreate']
|
|
67
104
|
@filter = optional['filter']
|
|
@@ -69,22 +106,24 @@ module RecombeeApiClient
|
|
|
69
106
|
@logic = optional['logic']
|
|
70
107
|
@expert_settings = optional['expertSettings']
|
|
71
108
|
@return_ab_group = optional['returnAbGroup']
|
|
109
|
+
@reql_expressions = optional['reqlExpressions']
|
|
72
110
|
@optional = optional
|
|
73
111
|
@timeout = 3000
|
|
74
112
|
@ensure_https = false
|
|
75
113
|
@optional.each do |par, _|
|
|
76
|
-
|
|
114
|
+
raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate filter booster logic
|
|
115
|
+
expertSettings returnAbGroup reqlExpressions].include? par
|
|
77
116
|
end
|
|
78
117
|
end
|
|
79
|
-
|
|
118
|
+
|
|
80
119
|
# HTTP method
|
|
81
120
|
def method
|
|
82
121
|
:post
|
|
83
122
|
end
|
|
84
|
-
|
|
123
|
+
|
|
85
124
|
# Values of body parameters as a Hash
|
|
86
125
|
def body_parameters
|
|
87
|
-
p =
|
|
126
|
+
p = {}
|
|
88
127
|
p['count'] = @count
|
|
89
128
|
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
|
|
90
129
|
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
|
|
@@ -93,16 +132,17 @@ module RecombeeApiClient
|
|
|
93
132
|
p['logic'] = @optional['logic'] if @optional.include? 'logic'
|
|
94
133
|
p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
|
|
95
134
|
p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
|
|
135
|
+
p['reqlExpressions'] = @optional['reqlExpressions'] if @optional.include? 'reqlExpressions'
|
|
136
|
+
|
|
96
137
|
p
|
|
97
138
|
end
|
|
98
|
-
|
|
139
|
+
|
|
99
140
|
# Values of query parameters as a Hash.
|
|
100
141
|
# name of parameter => value of the parameter
|
|
101
142
|
def query_parameters
|
|
102
|
-
|
|
103
|
-
params
|
|
143
|
+
{}
|
|
104
144
|
end
|
|
105
|
-
|
|
145
|
+
|
|
106
146
|
# Relative path to the endpoint
|
|
107
147
|
def path
|
|
108
148
|
"/{databaseId}/recomms/users/#{@user_id}/item-segments/"
|