algolia / gatsby-plugin-algolia

A plugin to push to Algolia based on graphQl queries
https://yarn.pm/gatsby-plugin-algolia
Apache License 2.0
178 stars 45 forks source link

Update without rewriting index #42

Closed jdozierezell closed 4 years ago

jdozierezell commented 4 years ago

Is it is possible to run the plugin so that it only updates the index selected rather than completely erasing and reinserting the objects?

The issue I'm having is that I'm wanting to use one index to search for both items on a Gatsby site and an offsite event platform. I'm pulling in the event data through a node process happening on a separate server, but when I go back and perform gatsby build on my site, the event data is removed.

If there's no way around this, I can simply pull all Algolia updates into the node process, but I'd like to keep it integrated within Gatsby if possible.

Haroenv commented 4 years ago

In that case you'll need a quite different process, since the items in the gatsby-generated index need to be deleted too, and for that you need to know which items were part of the previous index.

What you can do is fork the plugin, and instead of moving indices (what we do now), is marking the previous gatsby items with a filter in Algolia, fetching those before indexing, deciding what should be updated, and what deleted, and then do those actions directly on the live index.

Haroenv commented 4 years ago

This has been added as a feature with enablePartialUpdates: true in 0.8.0