Support » Plugin: WP Search with Algolia » Managing app IDs between environments

  • Resolved Jon Dingman


    I’m running into an issue when pushing code between environments and data indexing.

    I’m using LocalWP.

    Is there a best practice to efficiently manage environments and indexes and application IDs between environments?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Michael Beckwith


    The BenchPresser

    Looks like these can be defined as constants in your wp-config and they’ll be used first before the values in the options page.


    You could use those with different values based on your environment.

    That should work, thank you!

    @tw2113 additionally, I have my own search.js file which I’m loading up with some customizations, since I’m not using the native search functionality. I built my own and connected it to Algolia.

    The problem I’m trying to solve is that, at the moment, the app IDs and keys are hard coded into search.js (file I created), is there a better way to manage this across environments?

    const searchClient = algoliasearch( “8D1B221KTYC”, “235cde75a1b422212811408d39ac8d” );

    const search = instantsearch( {
    indexName: “localnew_searchable_posts”,
    searchFunction( helper ) {
    // Ensure we only trigger a search when there’s a query
    if ( helper.state.query ) {;
    } );

    Also to localize the indexName so it’s for that particular environment.


    Plugin Author Michael Beckwith


    The BenchPresser

    Why not make use of + any dev-specific PHP constants for this. you could define a new constant for the indexName along side your API keys, and then use that function above to grab the constants and get them output to the page. Then they would be in scope for the custom search file.

    @tw2113 I’m running into separate issues now with the prefix you mentioned above, I noted it on github.

    Ah I think I know what’s going on actually. I have just the prefix in the code, and I need to add “_searchable_posts” to it.

    Plugin Author Michael Beckwith


    The BenchPresser

    I think you have this covered again 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.