Tuesday, January 17, 2023

How to support multiple test environments on Coveo Non-Prod Org?

 When you onboard the Coveo search platform by default, you will get two organizations — Prod and Nod Prod, prod can manage the Live search experiences, and non-Prod by default can manage one of the test search experiences, e.g., search on stage platform.

But in most cases, you may need to support multiple test platforms to support various testing, e.g., UAT, Stage, etc.; in this post, let us see one of the approaches to support multiple environments, e.g., UAT, Stage on Coveo Non-Prod organization.

Here the assumption is UAT websites enabled with domains containing uat, e.g., test-site1.uat.com, and stage websites enabled with the domains containing stage test-site1.stage.com.

Login to the Coveo Admin console and select non-Prod organization.

Create two conditions to identify the UAT and Stage environments.

Add two Filter conditions to the query pipelines to filter the content based on the environment conditions defined in the earlier step (filter based on the environment).

Enable UAT/Stage sources — Enable the source (I am using a sitemap source) with both the stage and uat sitemap URLs.

The source index both stage and uat content, but the query pipeline filters the content based on the source_environment and renders it to the end user.

Enable the source_environment context variable to the search page; if you are using the Coveo search page, enable the below event handler — the event handler sets the DNS that accessed the search page to the source_environment context variable. If you are using API to access the search result, pass the source_environment as part of the API context.

Coveo.$$(document.getElementById('coveo-search')).on('buildingQuery', function(e, args) {
args.queryBuilder.addContextValue('source_environment', window.location.hostname);
});

Now when the user accesses the search result page from the stage environment, the stage content is displayed, and uat data is while accessing the UAT search result page.

Specifying the source_environment context variable while accessing the search result through API.

https://platform.cloud.coveo.com/rest/search/v2?organizationId=xxxx&searchHub=xxxxx&access_token=xxxxx&context={"country":"us","locale":"es","source_environment":"stage"}&q=xxxx

Refer to Coveo Search Implementation with AEM (Adobe Experience Manager) | by Albin Issac | Tech Learnings | Sep, 2022 | Medium | Tech Learnings for more details on enabling Coveo search for AEM websites.

No comments:

Post a Comment