Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions specs/realtime-personalization/common/enums.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
strategy:
type: string
enum:
- session
- hybrid
example: 'session'
8 changes: 8 additions & 0 deletions specs/realtime-personalization/common/parameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# path
UserToken:
name: userToken
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call this userID in all the personalization APIs.

in: path
required: true
description: Unique identifier representing a user for which to fetch the personalization profile.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: Unique identifier representing a user for which to fetch the personalization profile.
description: Unique identifier used to retrieve the personalization profile of a specific user.

schema:
$ref: '../../common/schemas/SearchParams.yml#/userToken'
44 changes: 44 additions & 0 deletions specs/realtime-personalization/common/schemas/user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
user:
type: object
additionalProperties: false
required:
- version
- userID
- search
properties:
version:
type: string
description: Version of the response format.
userID:
type: string
description: User ID of the user.
search:
type: object
description: |
Index personalization filters by index name.
additionalProperties:
$ref: '#/searchFilters'

searchFilters:
type: object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this allow us to store search configurations for multiple groups of indices, and have a dynamic name?

Example extracted from Francois' presentation:
Screenshot 2025-03-19 at 17 19 59

Not sure how we represent that in the spec though.

Copy link
Contributor Author

@benamib benamib Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attribute additionalProperties allows us to tell the generator that the key of the object can be dynamic but that the format of the value should be of type searchFilters.

I'm not fond of this method but we don't have too much choice to respect the response we want.
We could still challenge the response format to replace the objects by arrays which would make the specs clearer imo like:

...
"search": [
	{ "aliases": "abc", "strategy": "def", "filters": {...} }
]
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current specs the generated exemples looks like this :

{
  "version": "string",
  "userID": "string",
  "search": {
    "additionalProp1": {
      "indices": [
        "storefront",
        "storefront_price_asc",
        "storefront_price_desc"
      ],
      "strategy": "session",
      "filters": {
        "session": [
          "brand:Dyson<score=12>"
        ],
        "additionalProp1": {}
      },
      "additionalProp1": {}
    },
    "additionalProp2": {
      "indices": [
        "storefront",
        "storefront_price_asc",
        "storefront_price_desc"
      ],
      "strategy": "session",
      "filters": {
        "session": [
          "brand:Dyson<score=12>"
        ],
        "additionalProp1": {}
      },
      "additionalProp1": {}
    },
    "additionalProp3": {
      "indices": [
        "storefront",
        "storefront_price_asc",
        "storefront_price_desc"
      ],
      "strategy": "session",
      "filters": {
        "session": [
          "brand:Dyson<score=12>"
        ],
        "additionalProp1": {}
      },
      "additionalProp1": {}
    }
  },
  "additionalProp1": {}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the reason for this structure was so that the FE could retrieve the required attributes as quick as possible (it's more time consuming to filter an array based on a key than it is to get a specific key from a map).

This looks good for now, but if it causes issues we can rethink it

additionalProperties: false
properties:
indices:
type: array
items:
type: string
example: ['storefront', 'storefront_price_asc', 'storefront_price_desc']
strategy:
$ref: '../enums.yml#/strategy'
filters:
$ref: '#/searchFilter'

searchFilter:
type: object
additionalProperties: false
properties:
session:
type: array
items:
type: string
example: ['brand:Dyson<score=12>']
25 changes: 25 additions & 0 deletions specs/realtime-personalization/paths/getUser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
get:
tags:
- users
operationId: getUser
x-acl:
- recommendation
summary: Retrieve the user's personalization profile
description: Retrieves the user's personalization profiles containing search filters.
parameters:
- $ref: '../common/parameters.yml#/UserToken'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '../common/schemas/user.yml#/user'
'400':
$ref: '../../common/responses/BadRequest.yml'
'402':
$ref: '../../common/responses/FeatureNotEnabled.yml'
'403':
$ref: '../../common/responses/MethodNotAllowed.yml'
'404':
$ref: '../../common/responses/IndexNotFound.yml'
43 changes: 43 additions & 0 deletions specs/realtime-personalization/spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
openapi: 3.1.0
info:
title: Realtime Personalization API
description: TODO
version: 0.0.1
externalDocs:
# TODO: Update the URL
url: https://www.algolia.com/doc/guides/personalization/what-is-personalization/
description: |
Related guide: Algolia Realtime Personalization.
components:
securitySchemes:
appId:
$ref: '../common/securitySchemes.yml#/appId'
apiKey:
$ref: '../common/securitySchemes.yml#/apiKey'
servers:
- url: https://ai-personalization.{region}.algolia.com
variables:
region:
description: |
Use the URL that matches your [analytics region](https://dashboard.algolia.com/account/infrastructure/analytics).
enum: [eu, us]
default: eu
security:
- appId: []
apiKey: []
tags:
- name: users
x-displayName: Users
description: |
User profiles contains the search filters each user has for the different facets in your index.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
User profiles contains the search filters each user has for the different facets in your index.
User profiles contain search filters that personalize search results in real time.

x-tagGroups:
- name: General
tags:
- filters
paths:
# ######################
# ### Custom request ###
# ######################

/2/realtime/users/{userToken}:
$ref: 'paths/getUser.yml'
Loading