Documentation Center

Sharing an IQ Elasticsearch cluster across a staging and live website

If you host a staging website and a live website, each with their own Content Delivery environment, you might want the two to use the same Elasticsearch cluster, but different indexes for your IQ search feature. To achieve this, modify your scripts so that the indexes in both environments have different names.

About this task

By default, IQ search services installed in one Content Delivery environment have the same index names as those installed in another Content Delivery environment. So long as each environment uses its own Elasticsearch cluster, this is not a problem.

But if you want to use the same Elasticsearch cluster for both environments, you need to ensure that the index names are unique. You can achieve this by adding a startup argument to your Elasticsearch index installation scripts, or, if you do not use those, your microservice installation scripts.

Procedure

  1. If you are creating Elasticsearch indexes by using the separate indexes installation script, installElasticsearchIndexes (recommended in a production environment), then in your staging environment, open a PowerShell command shell (Windows) or a Unix command shell (Unix) and navigate to the installation media folder Content Delivery\resources\elasticsearch\.
  2. Run the shell script, supplying command line switches as needed, and add the command line switch -index-common-name-prefix PREFIX (Windows) or --index-common-name-prefix PREFIX (Unix), where PREFIX is a unique string (for example, staging- or stg-) that Content Delivery prepends to the names of your Elasticsearch indexes used in the staging environment.
  3. Alternatively, if you are creating Elasticsearch indexes as part of running the microservice installation scripts (as sometimes done in a development environment), then In the Content Delivery environment for your staging site, access the location of one of your IQ microservices.
  4. In the bin/ subdirectory, open either startup.ps1 (Windows) or startup.sh (Unix).
  5. Find the place where values are added to the command line arguments of the script, and, depending on your operating system, add one of the following lines:
    • If your operating system is Windows, add this line: $arguments+="--index.common.name.prefix=PREFIX"
    • If your operating system is Unix-based, add this line: ARGUMENTS+="--index.common.name.prefix=PREFIX"

    where PREFIX is a unique string (for example, staging- or stg-) that Content Delivery prepends to the names of your Elasticsearch indexes used in the staging environment. The value must be identical to that in the other startup scripts, and to that in installElasticsearchIndexes, if using.

  6. Restart all the services you changed.
  7. Your Elasticsearch indexes used in the staging environment now have a unique prefix that distinguishes them from those in the live environment. If you want, you can go through all the above steps on the live environment as well, adding a different unique prefix, called live- for example.