Skip to content
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

feat: accept multiple objectIDs #8

Merged
merged 6 commits into from
May 14, 2021
Merged

feat: accept multiple objectIDs #8

merged 6 commits into from
May 14, 2021

Conversation

francoischalifour
Copy link
Member

Description

In the context of a shopping cart, getting recommendations based on all items is a common pattern. This updates the API to accept multiple objectIDs as references to get recommendations from.

How it works

  • We get recommendations for each object ID passed to objectIDs via searchClient.getObjects, with a hitsPerPage value divided by the number of objectIDs
  • We then build an Algolia query for each of these recommendations
  • The recommendations can contain duplicate objectIDs, so we remove any duplications.
  • We sort the recommendations by their scores to merge the recommendations coming from all the objectIDs in a continuous way

Questions

  • We might want to sort before deduping so that the lowest scored version of the item gets removed?

This updates the API to accept multiple `objectID`s as references to get recommendations from.

In the context of a shopping cart, getting recommendations based on all items is a common pattern.
Copy link
Contributor

@Shipow Shipow left a comment

Choose a reason for hiding this comment

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

thanks!!!

Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

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

We might want to sort before deduping so that the lowest scored version of the item gets removed?

If it's possible to have 2 recommend score for the same objectID, yes

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
packages/react-recommendations/src/utils/sortBy.ts Outdated Show resolved Hide resolved
@francoischalifour
Copy link
Member Author

@shortcuts I noted it on my board—I'll take care of deduping correctly in another PR along with some tests.

@francoischalifour francoischalifour merged commit 7ebd2e7 into next May 14, 2021
@francoischalifour francoischalifour deleted the feat/objectIDs branch May 14, 2021 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants