Route search queries to query pipelines
Route search queries to query pipelines
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:
-
You can set up conditions for Query Pipelines in the Coveo Administration Console to route search queries to Query Pipelines dynamically. This is the recommended approach (see Condition-based pipeline routing).
-
You can force a Query Pipeline at the Sitecore instance level, in the
Coveo.SearchProvider.Custom.config
file (see Set the query pipeline to use for all indexes). -
You can force a Query Pipeline at the index level, in the
Coveo.SearchProvider.Custom.config
file (see Set the query pipeline to use for a specific index). -
You can force a Query Pipeline at the Coveo-powered search page level, in the Coveo Search Interface rendering settings (see Set the query pipeline to use in your Coveo-powered search page).
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.
Condition-based pipeline routing (recommended)
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 |
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 |
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 |
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
-
Open the Coveo-powered search page in the Sitecore Experience Editor.
-
Select the Coveo Search Interface rendering.
-
Select the Edit the rendering’s data source option in the floating toolbar. It should be the leftmost option.
-
Scroll to the Query Settings section in the dialog.
-
Specify the name of the Query Pipeline to apply in the
Query pipeline
field. -
Click OK.
-
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 |
Determining the query pipeline used for a search
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).