chrisdmacrae / atomic-algolia

An NPM package for running atomic updates to an Algolia indices
67 stars 13 forks source link

[RFC]Upgrade to algoliasearch>4 #37

Open ravivalluri opened 3 years ago

ravivalluri commented 3 years ago

Use case (user story) I would like to update the algoliasearch > 4.

Notes Some functions on the index need to be updated. Since Algolia might stop the support for 3 in the future, when are you planning to upgrade?

As a developer, I'm using this library in our production environment, I want to help upgrade
swamidass commented 2 years ago

The current version does not work correctly with algolia, determining that records always need to be updated for some configurations of the index.

It appears that all is required to do this is change getRemoteIndex to this implementation:

async function  getRemoteIndex(index) {
  let hits = [];
  await index.browseObjects({
    query: '', // Empty query will match all records
    batch: batch => {
      hits = hits.concat(batch);
    },
    attributesToRetrieve: ["*"]
  })
  return hits
}

And, of course, bump the algoliasearch version on package.json.

Would someone like to create a pull request after testing this on their set up?