Leverage Multiple Coveo Indexes

Typically, all sources in a given Coveo Cloud organization contribute items to the same Coveo index.

However, in some rare cases, having two or more distinct Coveo indexes in the same organization can be beneficial. For instance, one large index could be used for items related to the service and/or workplace use cases, while a second smaller and faster index could be used for items related to ecommerce.

This article explains how to add items and forward queries to a specific Coveo index in such a scenario.

Customers cannot create additional Coveo indexes on their own, nor should they require Coveo to do so for them under normal circumstances.

If having multiple Coveo indexes in the same organization is instrumental for a deployment, Coveo professionals will suggest this approach in the early phases of the project.

Step 1 - Retrieve a Specific Coveo Index Identifier

Use the GET /rest/organizations/{organizationId}/logicalindexes Index API operation to list all available Coveo indexes in a given Coveo Cloud organization.

Authenticate the request using an access token granting the View access level on the Logical Indexes domain in the target organization (see Adding and Managing API Keys).

In the body of a successful response, retrieve and store the id property of the object corresponding to the Coveo index you specifically want to add items and forward queries to.

GET https://platform.cloud.coveo.com/rest/organizations/mycoveocloudorganizationg8tp8wu3/logicalindexes HTTP/1.1
 
Accept: application/json
Authorization: Bearer **********-****-****-****-************

Successful response body (200 OK)

[
  {
    "id": "default",
    "name": "default",
    "organizationId": "mycoveocloudorganizationg8tp8wu3"
  },
  {
    "id": "mycoveocloudorganizationg8tp8wu3-3m577icm",
    "name": "Acme Catalog Index",
    "organizationId": "mycoveocloudorganizationg8tp8wu3"
  }
]

In this example, you would likely want to retrieve and store the id of the second object in the response body array.

From a Coveo Cloud API point of view, distinct Coveo indexes are referred to as logical indexes.

This can be explained by the fact that a given Coveo index usually has one or more mirrors for load balancing and scalability. A given logical index thus actually represents a group of identical Coveo indexes (i.e., a Coveo index and its mirrors).

However, for the sake of simplicity, this nuance is generally omitted in the official product documentation. A Coveo index and a logical index should thus usually be considered near synonyms.

Step 2 - Add Content to a Specific Coveo Index

  1. Use the Coveo Cloud administration console to configure a source that should contribute content to a specific, non-default Coveo index (see Add a New Source). Store the unique identifier of the newly created source (e.g., mycoveocloudorganizationg8tp8wu3-s2etiqjxk2qjwu7ozdymiscp6y).

    • Use a temporary name when creating the source (e.g., temp_catalog). This way, you can use a truly meaningful name when duplicating the source in the next sub-step.
    • Click the Add source button (not Add and build source) to create the source. This way, no content will be needlessly crawled and pulled into the default Coveo index.
  2. Use the POST rest/organizations/{organizationId}/sources/{sourceId}/duplicate Source API operation to duplicate the previously created source, setting the logicalIndex query parameter to the id of the Coveo index to which the source should contribute content (e.g., the id retrieved and stored at Step 1).

    Authenticate the request using an access token granting the Edit access level on the Sources domain in the target organization (see Adding and Managing API Keys).

     POST https://platform.cloud.coveo.com/rest/organizations/mycoveocloudorganizationg8tp8wu3/sources/mycoveocloudorganizationg8tp8wu3-s2etiqjxk2qjwu7ozdymiscp6y/duplicate?newSourceName=catalog&logicalIndex=mycoveocloudorganizationg8tp8wu3-3m577icm HTTP/1.1
     
     Content-Type: application/json
     Accept: application/json
     Authorization: Bearer **********-****-****-****-************
    

    Successful response body excerpt (201 Created)

     {
       ...
       "id": "mycoveocloudorganization8tp8wu3-rg7paembd5ss7tvnhkv2k4soqa",
       ...
       "logicalIndex": "mycoveocloudorganizationg8tp8wu3-3m577icm",
       ...
     }
    
    • The logicalIndex property of a source cannot be modified after that source has been created.
    • Duplicating a non-Push source automatically triggers a build on the duplicate.
  3. Optionally, use the administration console to delete the original source (see Delete an Existing Source).

  4. Repeat sub-steps 1, 2, and 3 as needed.

Step 3 - Send Queries to a Specific Coveo Index

In the query pipeline to which are routed queries that should target a specific, non-default Coveo index (e.g., the one whose id you retrieved and stored at Step 1), create a query parameter rule that sets the logicalIndex parameter to the desired value (see Adding and Managing Query Pipeline Query Parameters).

Query pipeline condition:

when $searchHub is "StoreSearch"

Query parameter rule definition:

override query logicalIndex: mycoveocloudorganizationg8tp8wu3-3m577icm