Skip to content

Commit 60e8e6d

Browse files
kai687shortcutsmillotp
authored
fix(specs): Personalization API (#2982)
Co-authored-by: Clément Vannicatte <vannicattec@gmail.com> Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
1 parent 8252415 commit 60e8e6d

File tree

10 files changed

+104
-40
lines changed

10 files changed

+104
-40
lines changed

generators/src/main/java/com/algolia/codegen/AlgoliaSwiftGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class AlgoliaSwiftGenerator extends Swift5ClientCodegen {
5757
"edit",
5858
"edittype",
5959
"errorbase",
60+
"eventtype",
6061
"exactonsinglewordquery",
6162
"exhaustive",
6263
"facetfilters",
@@ -68,8 +69,8 @@ public class AlgoliaSwiftGenerator extends Swift5ClientCodegen {
6869
"ignoreplurals",
6970
"indexsettingsassearchparams",
7071
"languages",
71-
"matchlevel",
7272
"matchedgeolocation",
73+
"matchlevel",
7374
"mixedsearchfilters",
7475
"mode",
7576
"numericfilters",
@@ -81,14 +82,14 @@ public class AlgoliaSwiftGenerator extends Swift5ClientCodegen {
8182
"promoteobjectids",
8283
"querytype",
8384
"rankinginfo",
84-
"rerankingapplyfilter",
8585
"redirect",
8686
"redirectruleindexmetadata",
8787
"redirectruleindexmetadatadata",
8888
"region",
8989
"removestopwords",
9090
"removewordsifnoresults",
9191
"renderingcontent",
92+
"rerankingapplyfilter",
9293
"searchparams",
9394
"searchparamsobject",
9495
"searchparamsquery",

specs/personalization/common/parameters.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ UserToken:
33
name: userToken
44
in: path
55
required: true
6-
description: userToken representing the user for which to fetch the Personalization profile.
6+
description: Unique identifier representing a user for which to fetch the personalization profile.
77
schema:
8-
type: string
9-
10-
# misc
11-
userToken:
12-
type: string
13-
description: userToken representing the user for which to fetch the Personalization profile.
8+
$ref: '../../common/schemas/SearchParams.yml#/userToken'

specs/personalization/common/schemas/eventScoring.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ eventScoring:
1010
$ref: 'personalizationStrategy.yml#/score'
1111
eventName:
1212
type: string
13-
description: The name of the event.
13+
description: Event name.
1414
eventType:
15-
type: string
16-
description: The type of the event.
15+
$ref: '#/EventType'
16+
17+
EventType:
18+
title: eventType
19+
type: string
20+
description: Event type.
21+
enum:
22+
- click
23+
- conversion
24+
- view

specs/personalization/common/schemas/facetScoring.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ facetScoring:
99
$ref: 'personalizationStrategy.yml#/score'
1010
facetName:
1111
type: string
12-
description: The name of the facet.
12+
description: Facet attribute name.

specs/personalization/common/schemas/personalizationStrategy.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,30 @@ personalizationStrategyParams:
88
properties:
99
eventScoring:
1010
type: array
11-
description: Scores associated with the events.
11+
description: |
12+
Scores associated with each event.
13+
14+
The higher the scores, the higher the impact of those events on the personalization of search results.
1215
items:
1316
$ref: 'eventScoring.yml#/eventScoring'
1417
facetScoring:
1518
type: array
16-
description: Scores associated with the facets.
19+
description: |
20+
Scores associated with each facet.
21+
22+
The higher the scores, the higher the impact of those events on the personalization of search results.
1723
items:
1824
$ref: 'facetScoring.yml#/facetScoring'
1925
personalizationImpact:
2026
type: integer
21-
description: 'The impact that personalization has on search results: a number between 0 (personalization disabled) and 100 (personalization fully enabled).'
27+
minimum: 0
28+
maximum: 100
29+
description: |
30+
Impact of personalization on the search results.
31+
32+
If set to 0, personalization has no impact on the search results.
2233
2334
# misc
2435
score:
2536
type: integer
26-
description: The score for the event.
37+
description: Event score.

specs/personalization/paths/deleteUserProfile.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ delete:
66
- recommendation
77
summary: Delete a user profile.
88
description: |
9-
Delete the user profile and all its associated data.
9+
Deletes a user profile.
1010
11-
Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile.
12-
13-
It might take a couple hours for the deletion request to be fully processed.
11+
The response includes a date and time when the user profile can safely be considered deleted.
1412
parameters:
1513
- $ref: '../common/parameters.yml#/UserToken'
1614
responses:
@@ -27,10 +25,12 @@ delete:
2725
- deletedUntil
2826
properties:
2927
userToken:
30-
$ref: '../common/parameters.yml#/userToken'
28+
$ref: '../../common/schemas/SearchParams.yml#/userToken'
3129
deletedUntil:
3230
type: string
33-
description: A date until which the data can safely be considered as deleted for the given user. Any data received after the `deletedUntil` date will start building a new user profile.
31+
description: |
32+
Date and time when the user profile can be safely considered to be deleted.
33+
Any events received after the `deletedUntil` date start a new user profile.
3434
'400':
3535
$ref: '../../common/responses/BadRequest.yml'
3636
'402':

specs/personalization/paths/getUserTokenProfile.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ get:
44
operationId: getUserTokenProfile
55
x-acl:
66
- recommendation
7-
summary: Get a user profile.
8-
description: |
9-
Get the user profile built from Personalization strategy.
10-
11-
The profile is structured by facet name used in the strategy. Each facet value is mapped to its score. Each score represents the user affinity for a specific facet value given the userToken past events and the Personalization strategy defined. Scores are bounded to 20. The last processed event timestamp is provided using the ISO 8601 format for debugging purposes.
7+
summary: Retrieve a user profile.
8+
description: Retrieves a user profile and their affinities for different facets.
129
parameters:
1310
- $ref: '../common/parameters.yml#/UserToken'
1411
responses:
@@ -26,13 +23,17 @@ get:
2623
- lastEventAt
2724
properties:
2825
userToken:
29-
$ref: '../common/parameters.yml#/userToken'
26+
$ref: '../../common/schemas/SearchParams.yml#/userToken'
3027
lastEventAt:
3128
type: string
32-
description: Date of last event update. (ISO-8601 format).
29+
description: Date and time of the last event from this user, in RFC 3339 format.
3330
scores:
3431
type: object
35-
description: The userToken scores.
32+
description: |
33+
Scores for different facet values.
34+
35+
Scores represent the user affinity for a user profile towards specific facet values,
36+
given the personalization strategy and past events.
3637
'400':
3738
$ref: '../../common/responses/BadRequest.yml'
3839
'402':

specs/personalization/paths/personalizationStrategy.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ get:
44
operationId: getPersonalizationStrategy
55
x-acl:
66
- recommendation
7-
summary: Get the current strategy.
8-
description: The strategy contains information on the events and facets that impact user profiles and personalized search results.
7+
summary: Retrieve the personalization strategy.
8+
description: Retrieves the current personalization strategy.
99
responses:
1010
'200':
1111
description: OK
@@ -28,8 +28,8 @@ post:
2828
operationId: setPersonalizationStrategy
2929
x-acl:
3030
- recommendation
31-
summary: Set a new strategy.
32-
description: A strategy defines the events and facets that impact user profiles and personalized search results.
31+
summary: Define the personalization strategy.
32+
description: Creates a new personalization strategy.
3333
requestBody:
3434
required: true
3535
content:
@@ -51,6 +51,7 @@ post:
5151
message:
5252
type: string
5353
description: A message confirming the strategy update.
54+
example: Strategy was successfully updated.
5455
'400':
5556
$ref: '../../common/responses/BadRequest.yml'
5657
'402':

specs/personalization/spec.yml

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,50 @@
11
openapi: 3.0.2
22
info:
33
title: Personalization API
4-
description: API powering the Personalization feature of Algolia.
4+
description: |
5+
The Personalization API lets you access user profiles built from the personalization strategy.
6+
7+
## Base URLs
8+
9+
The base URLs for requests to the Personalization API are:
10+
11+
- `https://personalization.us.algolia.com`
12+
- `https://personalization.eu.algolia.com`
13+
14+
Use the URL that matches your [analytics region](https://dashboard.algolia.com/account/infrastructure/analytics).
15+
16+
**All requests must use HTTPS.**
17+
18+
## Authentication
19+
20+
To authenticate your API requests, add these headers:
21+
22+
- `x-algolia-application-id`. Your Algolia application ID.
23+
- `x-algolia-api-key`. An API key with the necessary permissions to make the request.
24+
The required access control list (ACL) to make a request is listed in each endpoint's reference.
25+
26+
You can find your application ID and API key in the [Algolia dashboard](https://dashboard.algolia.com/account).
27+
28+
## Request format
29+
30+
Request bodies must be JSON objects.
31+
32+
## Response status and errors
33+
34+
The Personalization API returns JSON responses.
35+
Since JSON doesn't guarantee any specific ordering, don't rely on the order of attributes in the API response.
36+
37+
Successful responses return a `2xx` status. Client errors return a `4xx` status. Server errors are indicated by a `5xx` status.
38+
Error responses have a `message` property with more information.
39+
40+
## Version
41+
42+
The current version of the Personalization API is version 1, as indicated by the `/1/` in each endpoint's URL.
543
version: 1.0.0
44+
externalDocs:
45+
url: https://www.algolia.com/doc/guides/personalization/what-is-personalization/
46+
description: |
47+
Related guide: Algolia Personalization.
648
components:
749
securitySchemes:
850
appId:
@@ -23,10 +65,15 @@ security:
2365
tags:
2466
- name: profiles
2567
x-displayName: Profiles
26-
description: Manage users' profiles.
68+
description: |
69+
User profiles represent the affinities each user profile has for the different facets in your index.
70+
The more a user viewed and clicked search results with a specific facet,
71+
the higher the affinity for that facet.
2772
- name: strategies
2873
x-displayName: Strategies
29-
description: Manage personalization strategies.
74+
description: |
75+
The personalization strategy defines how personalization should affect the search results,
76+
and how much each facet and event type impact the personalization.
3077
x-tagGroups:
3178
- name: General
3279
tags:

tests/CTS/requests/personalization/setPersonalizationStrategy.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{
77
"score": 42,
88
"eventName": "Algolia",
9-
"eventType": "Event"
9+
"eventType": "click"
1010
}
1111
],
1212
"facetScoring": [
@@ -25,7 +25,7 @@
2525
{
2626
"score": 42,
2727
"eventName": "Algolia",
28-
"eventType": "Event"
28+
"eventType": "click"
2929
}
3030
],
3131
"facetScoring": [

0 commit comments

Comments
 (0)