A Coveo component I hadn't even heard up until quite recently, turns out to be something extremely powerful if you're looking at extending a Query Pipeline by injecting in some contextual data.
I'm of course referring to the PipelineContext Component. Its main purpose is for injecting custom contextual information into a user's search request along with UA search events.
An important note: this shouldn't be used as a way of dealing with security-related queries or queries that require specific permissions to elevate secured content. For that, you want to be updating the Coveo User Context via the Search Token. Anything you place within the PipelineContext is fair game to be manipulated.
Well, like most Coveo components, you're able to utilize this functionality very easily through the DOM.
It's not by adding the class to a
div element. In this case you're going to use a
script element. Have a look at this very simple example.
<script class="CoveoPipelineContext" type="text/context">
As you can see, the context itself is just an object we're able to assign a
This object can contain essentially whatever you want and through your application, you can derive the information in any number of ways. The big question though is how do you access this information?
With the custom data loaded, how is it used and how can it be used? There are two ways, one is automatic, the other is by enabling you to modify the Query Pipeline manually.
If you log into your Platform Admin and head to the Query Pipeline you have a few options of where to utilize the
One such place is you can add a Ranking Expression utilizing one or all of the context values you have provided. For example, you can generate a QRE such as the following applying a modifier.
$qre(expression: @country==$context.country, modifier: 250)
This thereby can boost the relevant content. Coveo ML will in turn learn from this behavior.
You can also enable conditions in the pipeline thereby only affecting your results if conditions within the context are present in the same manner. This can be done anywhere within the Query Pipeline that allows for a condition to be placed. You can create filters that are only applied under certain contexts or go as far as enabling a pipeline itself under certain conditions.
If you already have a
CoveoAnalytics component added to your Search Interface then that context data is automatically added to a property called
customData. This property is logged as part of the usage analytics event and prefixed by
Once that is done, the Coveo ML service can effectively learn from it. How awesome is that? The model will be able to promote content that matches that key-value pair.
As the information is logged via the Usage Analytics events, this data is then also available to those who have reporting capabilities within the Platform Admin. Generating reports based upon this information.
As you can see, by simply enhancing the context in which a search is conducted, both the end-user with those that manage and market the information can each receive more personalized information and thus enhance the experience.
Sign up to our bi-weekly newsletter for a bite-sized curation of valuable insight from the Sitecore community.