algolia / algoliasearch-jekyll

⚠ DEPRECATED Use jekyll-algolia instead.
https://community.algolia.com/jekyll-algolia/
MIT License
125 stars 12 forks source link

Error: API key cannot write to {index_name}_tmp index #43

Closed tomjoht closed 7 years ago

tomjoht commented 7 years ago

I'm trying to integrate Algolia with my Jekyll site by following the instructions here. The instructions say,

Note that your API key should have write access to both the index_name and _tmp suffixed version of it (eg. your_index_name and your_index_name_tmp) in the previous example). This is due to the way we do atomic pushes by pushing to a temporary index and then renaming it.

However, the instructions don't explain how to enable write access to index_name and _tmp. As a result, when I try to push my index, I get this error:

Algolia Error: API key cannot write to {index_name}_tmp index In order to do atomic pushes to your Algolia index, the plugin first pushes to a temporary index (suffixed with _tmp), then renames it.

You see this error because the plugin wasn't able to push to that {index_name}_tmp index, with the API key you provided.

Make sure the API key you're using has rights to write on both your index and its {index_name}_tmp suffixed version.

In my Algolia Dashboard, the Admin API key is the same for both of my indexes (the regular one and the _tmp) one. How do I give my index_tmp write access so that I don't get this error message when pushing my index from the command line?

pixelastic commented 7 years ago

Hello,

You need an API key that can push content to both index_name and index_name_tmp. You can use your Admin API key (because it has write access to all your indices), or create a custom key with only write access specific indices. I would suggest using a custom key, it is either to revoke in case it leaks.

To do that, you need to add a new key through your dashboard, and give it access to index_name* (note the * suffix), which means any index starting with index_name (which will include index_name_tmp). You also need to check the boxes at the bottom of the form to allow writing content and settings to this index.

I've added a screenshot: image

I've also updated the README to make it clearer. If you're still having troubles, let me know :)

tomjoht commented 7 years ago

Thanks. I did have the Admin API key initially when I encountered this message. I created a custom key like you suggested, and I was able to push just fine.