@@ -101,6 +101,69 @@ class RecommendItemSegmentsToItem(Request):
101101 :param return_ab_group: If there is a custom AB-testing running, return the name of the group to which the request belongs.
102102
103103
104+ :param reql_expressions: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
105+
106+ This can be used to compute additional properties of the recommended Item Segments.
107+
108+
109+ The keys are the names of the expressions, and the values are the actual ReQL expressions.
110+
111+
112+ Example request:
113+
114+ ```json
115+
116+ E{lb}
117+
118+ "reqlExpressions": E{lb}
119+
120+ "countItems": "size(segment_items(\" categories\" , 'segmentId'))"
121+ E{rb}
122+ E{rb}
123+
124+ ```
125+
126+
127+ Example response:
128+
129+ ```json
130+
131+ E{lb}
132+
133+ "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
134+
135+ "recomms":
136+
137+ [
138+
139+ E{lb}
140+
141+ "id": "category-fantasy-books",
142+
143+ "reqlEvaluations": E{lb}
144+
145+ "countItems": 486
146+ E{rb}
147+ E{rb},
148+
149+ E{lb}
150+
151+ "id": "category-sci-fi-costumes",
152+
153+ "reqlEvaluations": E{lb}
154+
155+ "countItems": 19
156+ E{rb}
157+ E{rb}
158+
159+ ],
160+
161+ "numberNextRecommsCalls": 0
162+ E{rb}
163+
164+ ```
165+
166+
104167 """
105168
106169 def __init__ (
@@ -115,6 +178,7 @@ def __init__(
115178 logic : Logic = DEFAULT ,
116179 expert_settings : dict = DEFAULT ,
117180 return_ab_group : bool = DEFAULT ,
181+ reql_expressions : dict = DEFAULT ,
118182 ):
119183 super ().__init__ (
120184 path = "/recomms/items/%s/item-segments/" % (item_id ),
@@ -132,6 +196,7 @@ def __init__(
132196 self .logic = logic
133197 self .expert_settings = expert_settings
134198 self .return_ab_group = return_ab_group
199+ self .reql_expressions = reql_expressions
135200
136201 def get_body_parameters (self ) -> dict :
137202 """
@@ -154,6 +219,8 @@ def get_body_parameters(self) -> dict:
154219 p ["expertSettings" ] = serialize_to_json (self .expert_settings )
155220 if self .return_ab_group is not DEFAULT :
156221 p ["returnAbGroup" ] = serialize_to_json (self .return_ab_group )
222+ if self .reql_expressions is not DEFAULT :
223+ p ["reqlExpressions" ] = serialize_to_json (self .reql_expressions )
157224
158225 return p
159226
0 commit comments