Atomic Algolia NPM Plugin

Hi everyone!

I want to share an NPM package I’ve developed for doing atomic updates to Algolia indices. It’s heavily inspired by @pixelastic’s jekyll-algolia plugin, and is simply a layer on top of algoliasearch.

The plugin allows you to:

  • Update a single index from a JSON file on your machine through an NPM script or the command line
  • Update one or more indices from JSON files on your machine using a custom JS script
  • Update one or more indices from a JS array using a custom JS script

In short, it compares the records in your Algolia index against the local records you’re adding, and ensures you use the least amount of operations possible.

I published a blog post on Forestry.io on using this plugin with a Jekyll site,

3 Likes

Hey Chris! Awesome work man! We’ll take a look at the blog post and see if we can further amplify it for you :slight_smile:

1 Like

Thanks @martynd! I’d love the circulation.

To give you an idea, in the Hugo SSG space (gohugo.io) my package saves almost 60% on operations compared to the leading solution, and does it 2-3x faster!

Hugo Algolia:

Atomic Algolia:

1 Like

This is really great, congrats @chrisdmacrae!

Having this logic in a stand-alone npm package means it will be much easier to implement atomic updates in many different scenarios. I can already see how it can be used with other static website generators, like Gatsby.

I’m still finding issues and edge-cases with my implementation on jekyll-algolia, but once I’ll have this iron out, I’ll come contribute to your package to port them there.

Thanks a lot for this amazing work!

1 Like

Thanks for the vote of confidence @pixelastic. Your plugin helped a lot with building this!

I’ve had a lot of chats with @budparr regarding some advanced usage like multiple indices, chunking records (like you do with paragraphs), and much more.

I’d love to collaborate on making this thing as powerful as possible!

2 Likes

We just published @chrisdmacrae’s article on how to implement searches on a static site :zap: by Hugo but also introduces his NPM plugin and how to use it with Serverless. Check it out :point_right: article

2 Likes