Understanding the Query Pipeline Routing Algorithm

When a query is sent to the Search API, a simple routing algorithm is executed to determine which query pipeline in the target Coveo Cloud organization will process this query.

The following diagram illustrates the process of a query being routed to a query pipeline.

Query Pipeline Routing Algorithm

When a query is sent to the Search API:

  1. If the search token enforces a pipeline, go to Step 4 using the search token-enforced pipeline (bypassing its condition, if any).

  2. Otherwise, if the query enforces a pipeline, go to Step 4 using the query-enforced pipeline (bypassing its condition, if any).

  3. Otherwise, for each pipeline that has a condition in the Coveo Cloud organization

    1. If the query meets the condition, go to Step 4 using the current pipeline.

    2. Otherwise, if the current pipeline is the last pipeline in the organization, go to Step 4 using the default pipeline (bypassing its condition, if any).

    3. Otherwise, repeat Step 3.a using the next pipeline.

  4. Route the query through the pipeline.

  • Unless a specific query pipeline is enforced (see Steps 1 and 2), pipelines with conditions are evaluated sequentially until a condition is satisfied (see Step 3). The order of evaluation of pipelines is based on the position attribute, which is automatically populated when a pipeline is created, and cannot be changed thereafter. In essence, this means that pipelines with conditions are typically evaluated from oldest to newest. This is slightly counter-intuitive, as pipelines are displayed in alphabetical order in the Coveo Cloud administration console. You can use the List query pipelines Search API operation to retrieve the actual position value of each pipeline in a Coveo Cloud organization.

  • It is possible for the default query pipeline to have a condition. When this is the case, the default pipeline may be evaluated just like any other pipeline with a condition (see Step 3). However, if the query does not satisfy the condition of any of the evaluated pipelines, it will ultimately be routed through the default pipeline, bypassing its condition.

Recommended Articles