Using a Query Pipeline
Using a Query Pipeline
Query pipelines are rules that can be specified to alter
- queries in the cloud, just before they’re sent to the index.
- results returned by the index, before they’re sent back to the search interface.
Query pipelines are defined in the Coveo Cloud Console (see Manage query pipelines).
There are four ways you can route your queries to Query Pipelines:
- You can set up conditions for Query Pipelines in the Coveo Cloud 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 component settings (see Set the Query Pipeline to Use in Your Coveo-Powered Search Page).
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’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).
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.
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>
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.
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 doesn’t match any Query Pipeline condition set in your Coveo organization, the Query Pipeline tagged as Default
in your Coveo organization is used.
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.
-
On a Coveo Hive search page, select the
Coveo Search Interface
component and select 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. -
On 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. -
Click OK.
-
Save your changes in the Experience Editor.
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.
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).