recombee_api_client 2.4.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ece07c27210eaca1d3ee2c818ec6c670d6266c9d
4
- data.tar.gz: 158f3b6e97b4bec261b56a96ef038a189f4ced9b
3
+ metadata.gz: a942eeaa73f8037bc616520dbf570cb1fd257dbf
4
+ data.tar.gz: d2baff7ca3c650a0f3486141262c83f95ace0726
5
5
  SHA512:
6
- metadata.gz: 4e927d93cdeeaa136c19a609cea566a6741db488be745735171c843cd3b3d9851a45c500c0a9efe57822be679507b0a5eeaff760262b59ec0ac3f635861a4356
7
- data.tar.gz: aa0d10e14be91db61f6e092dd70c74d92bdcbca06f02a19054c331ca4b570709e429235c791f8b16590cda6e4d9fae736ac5f871de13a5faa6aa4173c434539f
6
+ metadata.gz: 3bbea9fa0a442823d6b13a83fdb97c28bee3cc2776efc8082d5f620153a2efd5f1aece23ee72ecba7e6ec1d7af539b2e53ce4d937ba222327ae4071447e0c702
7
+ data.tar.gz: da781be2989614d534eec5b7f823f897dd0a8b8e3d6c9f399a9956a430e58fada2150cdcf3f0b62a94364b9f08e31a7f862e30bab48068b33611a158b4c1033f
data/README.md CHANGED
@@ -72,7 +72,7 @@ NUM = 100
72
72
  PROBABILITY_PURCHASED = 0.1
73
73
 
74
74
  client = RecombeeClient('--my-database-id--', '--db-private-token--')
75
- client.send(ResetDatabase.new) # Clear everything from the database
75
+ client.send(ResetDatabase.new) # Clear everything from the database (asynchronous)
76
76
 
77
77
  # We will use computers as items in this example
78
78
  # Computers have five properties
@@ -103,7 +103,7 @@ requests = (1..NUM).map do |i|
103
103
  },
104
104
  #optional parameters:
105
105
  {
106
- 'cascadeCreate' => true # Use cascadeCreate for creating item
106
+ :cascade_create => true # Use cascade_create for creating item
107
107
  # with given itemId, if it doesn't exist
108
108
  }
109
109
  )
@@ -117,29 +117,38 @@ requests = []
117
117
  (1..NUM).map{|i| "computer-#{i}"}.each do |item_id|
118
118
  user_ids = (1..NUM).map{|i| "user-#{i}"}
119
119
  user_ids = user_ids.select { |_| rand(0.0..1.0) < PROBABILITY_PURCHASED }
120
- # Use cascadeCreate to create unexisting users
121
- user_ids.each { |user_id| requests.push(AddPurchase.new(user_id, item_id, 'cascadeCreate' => true)) }
120
+ # Use cascade_create to create unexisting users
121
+ user_ids.each { |user_id| requests.push(AddPurchase.new(user_id, item_id, :cascade_create => true)) }
122
122
  end
123
123
 
124
124
  # Send purchases to the recommender system
125
125
  client.send(Batch.new(requests))
126
126
 
127
127
  # Get 5 recommendations for user-42, who is currently viewing computer-6
128
- recommended = client.send(RecommendItemsToItem.new('computer-6', 'user-42', 5) )
129
- puts "Recommended items: #{recommended}"
130
-
131
128
  # Recommend only computers that have at least 3 cores
132
129
  recommended = client.send(
133
- RecommendItemsToItem.new('computer-6', 'user-42', 5, {'filter' => "'num-cores'>=3"})
130
+ RecommendItemsToItem.new('computer-6', 'user-42', 5, {:filter => "'num-cores'>=3"})
134
131
  )
135
132
  puts "Recommended items with at least 3 processor cores: #{recommended}"
136
133
 
137
- # Recommend only items thatare more expensive then currently viewed item (up-sell)
134
+ # Recommend only items that are more expensive then currently viewed item (up-sell)
138
135
  recommended = client.send(
139
136
  RecommendItemsToItem.new('computer-6', 'user-42', 5,
140
- {'filter' => "'price' > context_item[\"price\"]"})
137
+ {:filter => "'price' > context_item[\"price\"]"})
141
138
  )
142
139
  puts "Recommended up-sell items: #{recommended}"
140
+
141
+ # Filters, boosters and other settings can be also set in the Admin UI (admin.recombee.com)
142
+ # when scenario is specified
143
+ recommended = client.send(
144
+ RecommendItemsToItem.new('computer-6', 'user-42', 5, {:scenario => 'product_detail'})
145
+ )
146
+
147
+ # Perform personalized full-text search with a user's search query (e.g. 'computers').
148
+ matches = client.send(
149
+ SearchItems.new('user-42', 'computers', 5)
150
+ )
151
+ puts "Matched items: #{matches}"
143
152
  ```
144
153
 
145
154
  ### Exception handling
@@ -18,7 +18,7 @@ module RecombeeApiClient
18
18
  include HTTParty
19
19
 
20
20
  BATCH_MAX_SIZE = 10000
21
- USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/2.4.0'}
21
+ USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/3.0.0'}
22
22
 
23
23
  ##
24
24
  # - +account+ -> Name of your account at Recombee
@@ -14,7 +14,7 @@ module RecombeeApiClient
14
14
  #The returned items are sorted by relevancy (first item being the most relevant).
15
15
  #
16
16
  class RecommendItemsToItem < ApiRequest
17
- attr_reader :item_id, :target_user_id, :count, :filter, :booster, :cascade_create, :scenario, :logic, :return_properties, :included_properties, :user_impact, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
17
+ attr_reader :item_id, :target_user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :user_impact, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
18
18
  attr_accessor :timeout
19
19
  attr_accessor :ensure_https
20
20
 
@@ -42,15 +42,13 @@ module RecombeeApiClient
42
42
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
43
43
  #
44
44
  # * *Optional arguments (given as hash optional)*
45
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
46
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
47
- # - +cascadeCreate+ -> If item of given *itemId* or user of given *targetUserId* doesn't exist in the database, it creates the missing entity/entities and returns some (non-personalized) recommendations. This allows for example rotations in the following recommendations for the user of given *targetUserId*, as the user will be already known to the system.
48
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application 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.
49
- # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
50
- #See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
45
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing".
51
46
  #
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.
47
+ #You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs.
53
48
  #
49
+ #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.
50
+ #
51
+ # - +cascadeCreate+ -> If item of given *itemId* or user of given *targetUserId* doesn't exist in the database, it creates the missing entity/entities and returns some (non-personalized) recommendations. This allows for example rotations in the following recommendations for the user of given *targetUserId*, as the user will be already known to the system.
54
52
  # - +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 for easy displaying of the recommended items to the user.
55
53
  #
56
54
  #Example response:
@@ -107,6 +105,21 @@ module RecombeeApiClient
107
105
  # }
108
106
  #```
109
107
  #
108
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
109
+ #
110
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
111
+ #
112
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
113
+ #
114
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
115
+ #
116
+ # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
117
+ #See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details.
118
+ #
119
+ #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
120
+ #
121
+ #Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
122
+ #
110
123
  # - +userImpact+ -> **Expert option** If *targetUserId* parameter is present, the recommendations are biased towards the given user. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0`.
111
124
  #
112
125
  # - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
@@ -127,13 +140,13 @@ module RecombeeApiClient
127
140
  @target_user_id = target_user_id
128
141
  @count = count
129
142
  optional = normalize_optional(optional)
130
- @filter = optional['filter']
131
- @booster = optional['booster']
132
- @cascade_create = optional['cascadeCreate']
133
143
  @scenario = optional['scenario']
134
- @logic = optional['logic']
144
+ @cascade_create = optional['cascadeCreate']
135
145
  @return_properties = optional['returnProperties']
136
146
  @included_properties = optional['includedProperties']
147
+ @filter = optional['filter']
148
+ @booster = optional['booster']
149
+ @logic = optional['logic']
137
150
  @user_impact = optional['userImpact']
138
151
  @diversity = optional['diversity']
139
152
  @min_relevance = optional['minRelevance']
@@ -145,7 +158,7 @@ module RecombeeApiClient
145
158
  @timeout = 3000
146
159
  @ensure_https = false
147
160
  @optional.each do |par, _|
148
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","logic","returnProperties","includedProperties","userImpact","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
161
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","userImpact","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
149
162
  end
150
163
  end
151
164
 
@@ -159,13 +172,13 @@ module RecombeeApiClient
159
172
  p = Hash.new
160
173
  p['targetUserId'] = @target_user_id
161
174
  p['count'] = @count
162
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
163
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
164
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
165
175
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
166
- p['logic'] = @optional['logic'] if @optional.include? 'logic'
176
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
167
177
  p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
168
178
  p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
179
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
180
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
181
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
169
182
  p['userImpact'] = @optional['userImpact'] if @optional.include? 'userImpact'
170
183
  p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
171
184
  p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
@@ -9,29 +9,31 @@ module RecombeeApiClient
9
9
  ##
10
10
  #Based on user's past interactions (purchases, ratings, etc.) with the items, recommends top-N items that are most likely to be of high value for a given user.
11
11
  #
12
+ #The most typical use cases are recommendations at homepage, in some "Picked just for you" section or in email.
13
+ #
12
14
  #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
13
15
  #
14
16
  #The returned items are sorted by relevancy (first item being the most relevant).
15
17
  #
16
18
  class RecommendItemsToUser < ApiRequest
17
- attr_reader :user_id, :count, :filter, :booster, :cascade_create, :scenario, :logic, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
19
+ attr_reader :user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
18
20
  attr_accessor :timeout
19
21
  attr_accessor :ensure_https
20
22
 
21
23
  ##
22
24
  # * *Required arguments*
23
- # - +user_id+ -> ID of the user for which personalized recommendations are to be generated.
25
+ # - +user_id+ -> ID of the user for whom personalized recommendations are to be generated.
24
26
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
25
27
  #
28
+ #
26
29
  # * *Optional arguments (given as hash optional)*
27
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
28
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
29
- # - +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.
30
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application 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.
31
- # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
32
- #See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
30
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing".
33
31
  #
34
- #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
32
+ #You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs.
33
+ #
34
+ #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.
35
+ #
36
+ # - +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.
35
37
  #
36
38
  # - +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 for easy displaying of the recommended items to the user.
37
39
  #
@@ -89,6 +91,21 @@ module RecombeeApiClient
89
91
  # }
90
92
  #```
91
93
  #
94
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
95
+ #
96
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
97
+ #
98
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
99
+ #
100
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
101
+ #
102
+ # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
103
+ #See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details.
104
+ #
105
+ #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
106
+ #
107
+ #Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
108
+ #
92
109
  # - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
93
110
  #
94
111
  # - +minRelevance+ -> **Expert option** Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevancy, and may return less than *count* items when there is not enough data to fulfill it.
@@ -106,13 +123,13 @@ module RecombeeApiClient
106
123
  @user_id = user_id
107
124
  @count = count
108
125
  optional = normalize_optional(optional)
109
- @filter = optional['filter']
110
- @booster = optional['booster']
111
- @cascade_create = optional['cascadeCreate']
112
126
  @scenario = optional['scenario']
113
- @logic = optional['logic']
127
+ @cascade_create = optional['cascadeCreate']
114
128
  @return_properties = optional['returnProperties']
115
129
  @included_properties = optional['includedProperties']
130
+ @filter = optional['filter']
131
+ @booster = optional['booster']
132
+ @logic = optional['logic']
116
133
  @diversity = optional['diversity']
117
134
  @min_relevance = optional['minRelevance']
118
135
  @rotation_rate = optional['rotationRate']
@@ -123,7 +140,7 @@ module RecombeeApiClient
123
140
  @timeout = 3000
124
141
  @ensure_https = false
125
142
  @optional.each do |par, _|
126
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","logic","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
143
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
127
144
  end
128
145
  end
129
146
 
@@ -136,13 +153,13 @@ module RecombeeApiClient
136
153
  def body_parameters
137
154
  p = Hash.new
138
155
  p['count'] = @count
139
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
140
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
141
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
142
156
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
143
- p['logic'] = @optional['logic'] if @optional.include? 'logic'
157
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
144
158
  p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
145
159
  p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
160
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
161
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
162
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
146
163
  p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
147
164
  p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
148
165
  p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
@@ -14,7 +14,7 @@ module RecombeeApiClient
14
14
  #The returned users are sorted by predicted interest in the item (first user being the most interested).
15
15
  #
16
16
  class RecommendUsersToItem < ApiRequest
17
- attr_reader :item_id, :count, :filter, :booster, :cascade_create, :scenario, :logic, :return_properties, :included_properties, :diversity, :expert_settings, :return_ab_group
17
+ attr_reader :item_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :diversity, :expert_settings, :return_ab_group
18
18
  attr_accessor :timeout
19
19
  attr_accessor :ensure_https
20
20
 
@@ -24,15 +24,13 @@ module RecombeeApiClient
24
24
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
25
25
  #
26
26
  # * *Optional arguments (given as hash optional)*
27
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
28
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
29
- # - +cascadeCreate+ -> If item of given *itemId* doesn't exist in the database, it creates the missing item.
30
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application 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.
31
- # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
32
- #See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
27
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing".
33
28
  #
34
- #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
29
+ #You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs.
35
30
  #
31
+ #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.
32
+ #
33
+ # - +cascadeCreate+ -> If item of given *itemId* doesn't exist in the database, it creates the missing item.
36
34
  # - +returnProperties+ -> With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying the recommended users.
37
35
  #
38
36
  #Example response:
@@ -83,6 +81,21 @@ module RecombeeApiClient
83
81
  # }
84
82
  #```
85
83
  #
84
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
85
+ #
86
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
87
+ #
88
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
89
+ #
90
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
91
+ #
92
+ # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
93
+ #See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details.
94
+ #
95
+ #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
96
+ #
97
+ #Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
98
+ #
86
99
  # - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
87
100
  #
88
101
  # - +expertSettings+ -> Dictionary of custom options.
@@ -94,13 +107,13 @@ module RecombeeApiClient
94
107
  @item_id = item_id
95
108
  @count = count
96
109
  optional = normalize_optional(optional)
97
- @filter = optional['filter']
98
- @booster = optional['booster']
99
- @cascade_create = optional['cascadeCreate']
100
110
  @scenario = optional['scenario']
101
- @logic = optional['logic']
111
+ @cascade_create = optional['cascadeCreate']
102
112
  @return_properties = optional['returnProperties']
103
113
  @included_properties = optional['includedProperties']
114
+ @filter = optional['filter']
115
+ @booster = optional['booster']
116
+ @logic = optional['logic']
104
117
  @diversity = optional['diversity']
105
118
  @expert_settings = optional['expertSettings']
106
119
  @return_ab_group = optional['returnAbGroup']
@@ -108,7 +121,7 @@ module RecombeeApiClient
108
121
  @timeout = 50000
109
122
  @ensure_https = false
110
123
  @optional.each do |par, _|
111
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","logic","returnProperties","includedProperties","diversity","expertSettings","returnAbGroup"].include? par
124
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","diversity","expertSettings","returnAbGroup"].include? par
112
125
  end
113
126
  end
114
127
 
@@ -121,13 +134,13 @@ module RecombeeApiClient
121
134
  def body_parameters
122
135
  p = Hash.new
123
136
  p['count'] = @count
124
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
125
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
126
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
127
137
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
128
- p['logic'] = @optional['logic'] if @optional.include? 'logic'
138
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
129
139
  p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
130
140
  p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
141
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
142
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
143
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
131
144
  p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
132
145
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
133
146
  p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
@@ -14,25 +14,23 @@ module RecombeeApiClient
14
14
  #The returned users are sorted by similarity (first user being the most similar).
15
15
  #
16
16
  class RecommendUsersToUser < ApiRequest
17
- attr_reader :user_id, :count, :filter, :booster, :cascade_create, :scenario, :logic, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
17
+ attr_reader :user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
18
18
  attr_accessor :timeout
19
19
  attr_accessor :ensure_https
20
20
 
21
21
  ##
22
22
  # * *Required arguments*
23
- # - +user_id+ -> User to which we find similar users
23
+ # - +user_id+ -> User to whom we find similar users
24
24
  # - +count+ -> Number of users to be recommended (N for the top-N recommendation).
25
25
  #
26
26
  # * *Optional arguments (given as hash optional)*
27
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended users based on the values of their attributes.
28
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some users based on the values of their attributes.
29
- # - +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.
30
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application 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.
31
- # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
32
- #See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
27
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing".
33
28
  #
34
- #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
29
+ #You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs.
35
30
  #
31
+ #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.
32
+ #
33
+ # - +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.
36
34
  # - +returnProperties+ -> With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying the recommended users.
37
35
  #
38
36
  #Example response:
@@ -83,9 +81,24 @@ module RecombeeApiClient
83
81
  # }
84
82
  #```
85
83
  #
84
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
85
+ #
86
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
87
+ #
88
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
89
+ #
90
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
91
+ #
92
+ # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
93
+ #See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details.
94
+ #
95
+ #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
96
+ #
97
+ #Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
98
+ #
86
99
  # - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended users be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
87
100
  #
88
- # - +minRelevance+ -> **Expert option** Specifies the threshold of how much relevant must the recommended users be. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of users equal to *count* at any cost. If there are not enough data (such as interactions or user properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends users of at least the requested relevancy, and may return less than *count* users when there is not enough data to fulfill it.
101
+ # - +minRelevance+ -> **Expert option** Specifies the threshold of how much relevant must the recommended users be. Possible values one of: "low", "medium", "high".
89
102
  #
90
103
  # - +rotationRate+ -> **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an user for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended users.
91
104
  #
@@ -100,13 +113,13 @@ module RecombeeApiClient
100
113
  @user_id = user_id
101
114
  @count = count
102
115
  optional = normalize_optional(optional)
103
- @filter = optional['filter']
104
- @booster = optional['booster']
105
- @cascade_create = optional['cascadeCreate']
106
116
  @scenario = optional['scenario']
107
- @logic = optional['logic']
117
+ @cascade_create = optional['cascadeCreate']
108
118
  @return_properties = optional['returnProperties']
109
119
  @included_properties = optional['includedProperties']
120
+ @filter = optional['filter']
121
+ @booster = optional['booster']
122
+ @logic = optional['logic']
110
123
  @diversity = optional['diversity']
111
124
  @min_relevance = optional['minRelevance']
112
125
  @rotation_rate = optional['rotationRate']
@@ -117,7 +130,7 @@ module RecombeeApiClient
117
130
  @timeout = 50000
118
131
  @ensure_https = false
119
132
  @optional.each do |par, _|
120
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","logic","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
133
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
121
134
  end
122
135
  end
123
136
 
@@ -130,13 +143,13 @@ module RecombeeApiClient
130
143
  def body_parameters
131
144
  p = Hash.new
132
145
  p['count'] = @count
133
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
134
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
135
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
136
146
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
137
- p['logic'] = @optional['logic'] if @optional.include? 'logic'
147
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
138
148
  p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
139
149
  p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
150
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
151
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
152
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
140
153
  p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
141
154
  p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
142
155
  p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
@@ -0,0 +1,171 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
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).
11
+ #
12
+ #All the string and set item properties are indexed by the search engine.
13
+ #
14
+ #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.
15
+ #
16
+ #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
17
+ #
18
+ #The returned items are sorted by relevancy (first item being the most relevant).
19
+ #
20
+ class SearchItems < ApiRequest
21
+ attr_reader :user_id, :search_query, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :expert_settings, :return_ab_group
22
+ attr_accessor :timeout
23
+ attr_accessor :ensure_https
24
+
25
+ ##
26
+ # * *Required arguments*
27
+ # - +user_id+ -> ID of the user for whom personalized search will be performed.
28
+ # - +search_query+ -> Search query provided by the user. It is used for the full-text search.
29
+ # - +count+ -> Number of items to be returned (N for the top-N results).
30
+ #
31
+ # * *Optional arguments (given as hash optional)*
32
+ # - +scenario+ -> Scenario defines a particular search field in your user interface.
33
+ #
34
+ #You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each field performs.
35
+ #
36
+ #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.
37
+ #
38
+ # - +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.
39
+ # - +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 for easy displaying of the recommended items to the user.
40
+ #
41
+ #Example response:
42
+ #```
43
+ # {
44
+ # "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
45
+ # "recomms":
46
+ # [
47
+ # {
48
+ # "id": "tv-178",
49
+ # "values": {
50
+ # "description": "4K TV with 3D feature",
51
+ # "categories": ["Electronics", "Televisions"],
52
+ # "price": 342,
53
+ # "url": "myshop.com/tv-178"
54
+ # }
55
+ # },
56
+ # {
57
+ # "id": "mixer-42",
58
+ # "values": {
59
+ # "description": "Stainless Steel Mixer",
60
+ # "categories": ["Home & Kitchen"],
61
+ # "price": 39,
62
+ # "url": "myshop.com/mixer-42"
63
+ # }
64
+ # }
65
+ # ]
66
+ # }
67
+ #```
68
+ #
69
+ # - +includedProperties+ -> Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
70
+ #
71
+ #Example response for `includedProperties=description,price`:
72
+ #```
73
+ # {
74
+ # "recommId": "a86ee8d5-cd8e-46d1-886c-8b3771d0520b",
75
+ # "recomms":
76
+ # [
77
+ # {
78
+ # "id": "tv-178",
79
+ # "values": {
80
+ # "description": "4K TV with 3D feature",
81
+ # "price": 342
82
+ # }
83
+ # },
84
+ # {
85
+ # "id": "mixer-42",
86
+ # "values": {
87
+ # "description": "Stainless Steel Mixer",
88
+ # "price": 39
89
+ # }
90
+ # }
91
+ # ]
92
+ # }
93
+ #```
94
+ #
95
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
96
+ #
97
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
98
+ #
99
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
100
+ #
101
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
102
+ #
103
+ # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
104
+ #See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details.
105
+ #
106
+ #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
107
+ #
108
+ #Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
109
+ #
110
+ # - +expertSettings+ -> Dictionary of custom options.
111
+ #
112
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return name of group to which the request belongs.
113
+ #
114
+ #
115
+ def initialize(user_id, search_query, count, optional = {})
116
+ @user_id = user_id
117
+ @search_query = search_query
118
+ @count = count
119
+ optional = normalize_optional(optional)
120
+ @scenario = optional['scenario']
121
+ @cascade_create = optional['cascadeCreate']
122
+ @return_properties = optional['returnProperties']
123
+ @included_properties = optional['includedProperties']
124
+ @filter = optional['filter']
125
+ @booster = optional['booster']
126
+ @logic = optional['logic']
127
+ @expert_settings = optional['expertSettings']
128
+ @return_ab_group = optional['returnAbGroup']
129
+ @optional = optional
130
+ @timeout = 3000
131
+ @ensure_https = false
132
+ @optional.each do |par, _|
133
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","expertSettings","returnAbGroup"].include? par
134
+ end
135
+ end
136
+
137
+ # HTTP method
138
+ def method
139
+ :post
140
+ end
141
+
142
+ # Values of body parameters as a Hash
143
+ def body_parameters
144
+ p = Hash.new
145
+ p['searchQuery'] = @search_query
146
+ p['count'] = @count
147
+ p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
148
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
149
+ p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
150
+ p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
151
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
152
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
153
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
154
+ p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
155
+ p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
156
+ p
157
+ end
158
+
159
+ # Values of query parameters as a Hash.
160
+ # name of parameter => value of the parameter
161
+ def query_parameters
162
+ params = {}
163
+ params
164
+ end
165
+
166
+ # Relative path to the endpoint
167
+ def path
168
+ "/{databaseId}/search/users/#{@user_id}/items/"
169
+ end
170
+ end
171
+ end
@@ -20,7 +20,7 @@ module RecombeeApiClient
20
20
 
21
21
  ##
22
22
  # * *Required arguments*
23
- # - +user_id+ -> ID of the user for which the personalized recommendations are to be generated.
23
+ # - +user_id+ -> ID of the user for whom the personalized recommendations are to be generated.
24
24
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
25
25
  #
26
26
  # * *Optional arguments (given as hash optional)*
@@ -1,3 +1,3 @@
1
1
  module RecombeeApiClient
2
- VERSION = '2.4.0'
2
+ VERSION = '3.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recombee_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Fiedler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-11 00:00:00.000000000 Z
11
+ date: 2020-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -153,6 +153,7 @@ files:
153
153
  - lib/recombee_api_client/api/remove_from_series.rb
154
154
  - lib/recombee_api_client/api/request.rb
155
155
  - lib/recombee_api_client/api/reset_database.rb
156
+ - lib/recombee_api_client/api/search_items.rb
156
157
  - lib/recombee_api_client/api/set_item_values.rb
157
158
  - lib/recombee_api_client/api/set_user_values.rb
158
159
  - lib/recombee_api_client/api/set_values.rb