How to bind a specific Algolia index to a site that gets automatically generated by a Pull Request

Hi:

We use Netlify to support our Gatsby site. We have three related build sites: prod, staging, and dev. Also, we have it so that Netlify will create a temporary site when we git push against a specific pull request (PR) bound to a branch derived from the dev branch.

We are having trouble configuring Netlify so that when a build happens in the PR site, the build binds to and updates a specific index in Algolia.

We did try fiddling around in Netlfiy with the environment variable that declares the Alogolia index we want the PR build to bind to. But the PR build and the site are binding to the Alogia index used by the dev, staging and prod. branchs.

Tell me please, how do we make it so the dynamically created site formed when a developer pushes to a particular feature branch binds to a particular index name in Algolia?

@reselbob01 Are you using some kind of plugin like this one or is this a custom integration that you have with Algolia that’s performed during your build?

This sounds like the right approach to me.
Provided you can accurately identify that the build executing is the “one thought of as X” it should be trivial to get the build code to do Y when X.

Here is our fix:

We found that in regard to Netlify environment variables applicable to our code base, each variable can have different values based on the deploy context. For the ALGOLIA_INDEX_NAME and GATSBY_INDEX_NAME , we set our_release_index for Production and Branch deploys , and our_feature_index for Deploy previews and local development (Netlify CLI).
When the client pushes updates to our Bitbucket repo, Netlify will trigger a deploy preview and use our_feature_index as the index name. For production or branch deploys (the branch is develop), it will use our_release_index as the index name.

@reselbob01 The opening sentence there looks like it might be a typo, I presume you’ve resolved it and are describing the solution that you put together?

Can you confirm if this is for just your own code or for working with something pre-existing like a particular plugin?

Does my edit help @nathanmartin ?

Yes! it does, thanks @reselbob01

I just just making sure that I understood the situation, great to hear you were able to self solve.