Coveo for Sitecore 5 is now available!

Routing Search Queries to Query Pipelines

You have created one or several Query Pipeline(s) and you now want to specify which Query Pipeline your search queries should use.

In Coveo for Sitecore, you can specify which Query Pipeline your search queries should be routed to at three levels:

  • at the Sitecore instance level, in the Coveo.SearchProvider.Custom.config file
  • at the index level, in the Coveo.SearchProvider.Custom.config file
  • at the Coveo-powered search page level, in the Coveo Search Interface component settings

You can also route your search queries to Query Pipelines based on conditions specified in the Coveo Cloud Administration Console.

This article explains how to configure the Query Pipeline routing for each of these options.

When no pipeline is explicitly specified, the pipeline tagged as Default in your Coveo organization is used.

Set the Query Pipeline to Use for All Indexes

In your Coveo.SearchProvider.config file, locate the defaultIndexConfiguration/queryConfiguration section. Copy and paste it in your Coveo.SearchProvider.Custom.config file, under defaultIndexConfiguration.

Set the value of the queryPipelineName element with your query pipeline name.

<defaultIndexConfiguration type="Coveo.AbstractLayer.CoveoDefaultIndexConfiguration, Coveo.AbstractLayer">
  ...
  <!-- Coveo Query configuration -->
  <queryConfiguration type="Coveo.Framework.Configuration.QueryConfiguration, Coveo.Framework">
    ...
    <!-- The queryPipelineName element defines the query pipeline name to use in queries. Leave this field empty to use the default query pipeline. -->
    <queryPipelineName>myQueryPipelineName</queryPipelineName>
  </queryConfiguration>
  ...
</defaultIndexConfiguration>

Set the Query Pipeline to Use for a Specific Index

In your Coveo.SearchProvider.config file, locate the contentSearch section. Copy it, and add it to your Coveo.SearchProvider.Custom.config file.

Under configuration/indexes, if not already done, change the configuration element of the specific index to override the queryConfiguration section and set the queryPipelineName.

<index id="Coveo_master_index" type="Coveo.SearchProvider.ProviderIndex, Coveo.SearchProvider" patch:before = "*[1]">
  <param desc="p_Name">$(id)</param>
  <configuration ref="coveo/defaultIndexConfiguration">
    <queryConfiguration ref="coveo/defaultIndexConfiguration/queryConfiguration">
      <!-- The queryPipelineName element defines the query pipeline name to use in queries. Leave this field empty to use the default query pipeline. -->
      <queryPipelineName>myQueryPipelineName</queryPipelineName>
    </queryConfiguration>
  </configuration>
</index>

Set the Query Pipeline to Use in Your Coveo-Powered Search Page

You can override your Coveo.SearchProvider.Custom.config file configurations by specifying the pipeline to use directly in a Coveo-powered search page.

To specify the query pipeline to use in a search page

  1. Open the Coveo-powered search page in the Sitecore Experience Editor.
  2. Select the Coveo Search Interface component.
  3. Select the Edit the rendering’s data source option in the floating toolbar. It should be the leftmost option.
  4. Scroll to the Query Settings section in the dialog.
  5. Specify the name of the pipeline to apply in the Query pipeline field.

  6. Click OK.
  7. Save your changes in the Experience Editor.

Condition-Based Pipeline Routing

As an alternative to hardcoding the pipeline that’s applied to all your queries, this method allows you to associate conditions to your pipelines. Your query is evaluated against each condition. Upon the first match, the associated pipeline is applied (see Condition-Based Routing).

For troubleshooting purposes, it’s useful to know which query pipeline your search page is using for a specific search. This information is available through the browser developer tools (see Determine Which Query Pipeline a Search Page Uses).

What's Next for Me?