- 
                Notifications
    
You must be signed in to change notification settings  - Fork 27
 
feat(clients): add new realtime-personalization api #4613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from 2 commits
      Commits
    
    
            Show all changes
          
          
            25 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      75fdf13
              
                feat(realtime-perso): add new realtime-perso api
              
              
                 8828aa5
              
                update api url and path
              
              
                 3dfbf35
              
                Merge remote-tracking branch 'origin/main' into PRED-3652/realtime-pe…
              
              
                 2526e89
              
                update path and schemas
              
              
                 8ee8999
              
                update clients config
              
              
                 dedef01
              
                Merge remote-tracking branch 'origin/main' into PRED-3652/realtime-pe…
              
              
                 ca169fe
              
                Merge remote-tracking branch 'origin/main' into PRED-3652/realtime-pe…
              
              
                 283ce30
              
                try without additionalPropoerties
              
              
                 a2965f7
              
                rollback change
              
              
                 e54f457
              
                Merge branch 'main' into PRED-3652/realtime-perso-api
              
              
                benamib 0d9a3c8
              
                fix: go
              
              
                shortcuts 9d48a55
              
                chore: playground and javascript
              
              
                shortcuts af4f5ea
              
                chore: go cts
              
              
                shortcuts 2b5bc83
              
                chore: add a test
              
              
                shortcuts 533cf7b
              
                chore: dart
              
              
                shortcuts 16c351d
              
                chore: client tests
              
              
                shortcuts d84057a
              
                chore: generation issues
              
              
                shortcuts b355500
              
                chore: pre-release
              
              
                shortcuts ee86911
              
                chore: lock
              
              
                shortcuts 043b672
              
                chore: dart
              
              
                shortcuts 9d643d6
              
                chore: build
              
              
                shortcuts 4f7426b
              
                chore: cts
              
              
                shortcuts 7ec3c20
              
                chore: cts
              
              
                shortcuts efac20c
              
                chore: cts
              
              
                shortcuts d9c9219
              
                chore: js snippets
              
              
                shortcuts File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| strategy: | ||
| type: string | ||
| enum: | ||
| - session | ||
| - hybrid | ||
| example: 'session' | 
        
          
          
            20 changes: 0 additions & 20 deletions
          
          20 
        
  specs/realtime-personalization/common/schemas/personalizationFilters.yml
  
  
      
      
   
        
      
      
    This file was deleted.
      
      Oops, something went wrong.
      
    
  
        
          
          
            30 changes: 0 additions & 30 deletions
          
          30 
        
  specs/realtime-personalization/common/schemas/searchFilters.yml
  
  
      
      
   
        
      
      
    This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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 | ||
| 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>'] | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| 
          
            
          
           | 
    @@ -18,19 +18,18 @@ servers: | |||||
| - url: https://ai-personalization.{region}.algolia.com | ||||||
                
      
                  benamib marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||||||
| variables: | ||||||
| region: | ||||||
| enum: | ||||||
| - us | ||||||
| - eu | ||||||
| default: us | ||||||
| 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: filters | ||||||
| x-displayName: Filters | ||||||
| - name: users | ||||||
| x-displayName: Users | ||||||
| description: | | ||||||
| Filters are used to personalize the search results for a user. | ||||||
| They are used to filter the search results based on the user's preferences. | ||||||
| User profiles contains the search filters each user has for the different facets in your index. | ||||||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
        Suggested change
       
    
  | 
||||||
| x-tagGroups: | ||||||
| - name: General | ||||||
| tags: | ||||||
| 
        
          
        
         | 
    @@ -40,5 +39,5 @@ paths: | |||||
| # ### Custom request ### | ||||||
| # ###################### | ||||||
| 
     | 
||||||
| /2/realtime/{userToken}: | ||||||
| $ref: 'paths/getPersonalizationFilters.yml' | ||||||
| /2/realtime/users/{userToken}: | ||||||
| $ref: 'paths/getUser.yml' | ||||||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
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:

Not sure how we represent that in the spec though.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The attribute
additionalPropertiesallows us to tell the generator that the key of the object can be dynamic but that the format of the value should be of typesearchFilters.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:
There was a problem hiding this comment.
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": {} }There was a problem hiding this comment.
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