I want to move my Algolia configuration from dev env to QA

I want to move my Algolia configuration from dev env to QA. Other than manually adding the configurations, is there a way to automate this using CI/CD pipeline? Algolia CLI is still not available for Linux and Windows, please suggest how this can be achieved using bitbucket pipeline.

1 Like

Hi @tina.oswal

The Algolia CLI is absolutely available for Linux, just not via a package manager. You just need to wget/curl the CLI from Github for instance:

  1. wget https://github.com/algolia/cli/releases/download/v1.2.0/algolia_1.2.0_linux_386.tar.gz
  2. Unpack the archive: tar xvf algolia_*_linux_*.tar.gz
  3. Optional: move the binary to a directory where you can execute it globally, for example, /usr/local/bin

There are also .deb and .rpm versions available depending on your CI/CD tool chain.

This is absolutely the best way to promote,. migrate, and snapshot configuration for your indices. Otherwise you will need to write custom code against our API to get the same effect.

I’m going to dig into if we have a canonical example you can use for this yet (installing, setting up a profile, etc). If not this may be worth building a blog post around!

Out of curiosity, what is your CI/CD tool chain?

Hi @chuck.meyer ,
Thank you for your response. We are using bitbucket pipeline for CI/CD. It would be good if you can share some example of how this can be achieved using Algolia CLI.
I am looking to promote the index settings (searchable attributes, rules, etc…) to different environments.
Inputs on this will really be helpful.
Thanks in advance.

1 Like

Agreed! I’ve asked around and so far haven’t found anyone who’s built a canonical example, but this is 100% a function of the CLI.

I want to try to build something as a GitHub action – the pattern should carry over to Bitbucket. It’ll be a couple of days before I can dig into this though.

Okay, I will wait to see something that I can refer for my work. Thank you again.

1 Like

You can use the APIs to pull the config, and load it into another App / Index…

curl -X GET \
-H "X-Algolia-API-Key: myapikey" \
-H "X-Algolia-Application-Id: myappid" \
"https://myappid-dsn.algolia.net/1/indexes/myDevIndexName/settings?getVersion=2" > devIndexConfigBackup.json

curl -X PUT \
-H "X-Algolia-API-Key: myapikey" \
-H "X-Algolia-Application-Id: myappid" \
-d "@devIndexConfigBackup.json" \
"https://myappid-dsn.algolia.net/1/indexes/myQAIndexName/settings?forwardToReplicas=true"

This only works if you are moving non-virtual replicas…
For virtual replicas, the PUT command has some limitations, and not all the settings returned in the GET will be applyable via the PUT… you might have to trim out some of the GET’s response to make that work.

Thank you @rudolf.ingerl. I am able to copy the index settings from one app to another. And like you mentioned there was a problem with the replicas settings. While the standard replicas did not get any setting from the primary, the virtual replicas got only the searchable attributes.
I also tried using the same get and put command for the replica index and its seems to be working fine. But only thing is i will need to run this command for the primary index as well as all the replica indices. I am not sure if this is the right approach. But is there any other way by which we can copy the replica settings also?
Do you think copyIndex will work here for replicas?

Thank you for your help.