Coveo for Sitecore 5 is now available!

Using a Query Pipeline

Query pipelines are rules that can be specified to alter

  • queries in the cloud, just before they are sent to the index.
  • results returned by the index, before they are sent back to the search interface.

Query pipelines are defined in the Coveo Cloud Console (see Adding and Managing Query Pipelines).

There are four ways you can route your queries to Query Pipelines:

Using condition-based routing not only allows you to draw upon query context to send searches dynamically to the most suitable Query Pipeline, but it also makes it possible to compare the performance of different Query Pipelines (see Condition-Based Pipeline Routing).

This article explains how to perform the necessary configurations for each Query Pipeline routing option.

Condition-Based Pipeline Routing

As an alternative to hard-coding the Query Pipeline that is applied to all your queries, this method allows you to associate conditions to your Query Pipelines. Your query is evaluated against each condition. Upon the first match, the associated Query Pipeline is applied (see Condition-Based Routing).

When no Query Pipeline is explicitly specified in Coveo for Sitecore and the query does not match any Query Pipeline condition set in your Coveo Cloud organization, the Query Pipeline tagged as Default in your Coveo Cloud organization is used.

Using condition-based routing and multiple Query Pipelines facilitates the comparison of Query Pipeline performance through A/B testing (see Adding and Managing A/B Tests).

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>

When no Query Pipeline is explicitly specified in Coveo for Sitecore and the query does not match any Query Pipeline condition set in your Coveo Cloud organization, the Query Pipeline tagged as Default in your Coveo Cloud organization is used.

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>

When no Query Pipeline is explicitly specified in Coveo for Sitecore and the query does not match any Query Pipeline condition set in your Coveo Cloud organization, the Query Pipeline tagged as Default in your Coveo Cloud organization is used.

Set the Query Pipeline to Use in Your Coveo Search Page

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

To specify the Query Pipeline to use in a search page

  1. Open the Coveo search page in the Sitecore Experience Editor.
  2. In a Coveo Hive search page, select the Coveo Search Interface component and click the Edit the rendering’s data source option in the floating toolbar. It should be the leftmost option.

    In a Legacy Search UI search page, select the Coveo Search View component and click the Edit Properties option in the floating toolbar. It should be the leftmost option.

  3. In a Coveo Hive search page, scroll to the Query Settings section in the dialog and specify the name of the pipeline to use in the Query pipeline field.

    In a Legacy Search UI search page, scroll to the Advanced section in the dialog and specify the name of the pipeline to use in the Query pipeline name field.

  4. Click OK.
  5. Save your changes in the Experience Editor.

When no Query Pipeline is explicitly specified in Coveo for Sitecore and the query does not match any Query Pipeline condition set in your Coveo Cloud organization, the Query Pipeline tagged as Default in your Coveo Cloud organization is used.

For troubleshooting purposes, it is 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 Determining Which Coveo Cloud Query Pipeline a Search Page Uses).