Route Search Queries to Query Pipelines

Warning
Legacy feature

This article pertains to the Coveo Hive framework which is now in maintenance mode.

Choose one of Coveo’s more modern, lightweight, and responsive libraries for any future search interface development. See the search interface Implementation guide for more details.

You’ve created one or several Query Pipelines in the Coveo Administration Console (see What’s a query pipeline?). You now want to specify which Query Pipeline your search queries should use.

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

Tip
Leading practice

Using condition-based routing not only lets you 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).

Note

Query Pipeline configurations can be copied across organizations using the Resource Snapshot feature. This can help you streamline your development and deployment process.

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

As an alternative to hard-coding the Query Pipeline that’s 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).

Note

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

35455165

Using condition-based routing and many Query Pipelines eases the comparison of Query Pipeline performance through A/B testing (see Manage 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>
Note

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

35455165

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>
Note

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

35455165

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 Query 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 rendering.

  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 Query Pipeline to apply in the Query pipeline field.

    SpecifyingQueryPipelineToUse
  6. Click OK.

  7. Save your changes in the Experience Editor.

Note

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

35455165

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).