Gravatar for steven.leslie@mulesoft.com

Question by Steven Leslie, Sep 13, 2018 7:36 PM

Is there a way to specify a query pipeline when using Coveo.SearchEndpoint?

Hi all,

Were using the following code to implement Coveo search in our UI:

Coveo.SearchEndpoint.endpoints['default'] = new Coveo.SearchEndpoint({
restUri: 'https://platform.cloud.coveo.com/rest/search',
accessToken: '<access_token>',
})

This works fine, but I can't figure out how to use a custom Query Pipeline. Would this require pointing to a custom endpoint (the above uses default)? I can find anything in the docs on how to create a custom endpoint.

Thanks in advance!

2 Replies
Gravatar for flguillemette@coveo.com

Answer by François Lachance-Guillemette, Sep 13, 2018 7:49 PM

There are a lot of events provided by the Coveo JavaScript Search Framework.

The one you are looking for is a query event, `buildingQuery`.

The arguments passed to this events contains the `queryBuilder` variable that you can use to modify the query. Here are the properties that you can use:

Coveo JavaScript Search Framework - QueryBuilder

The one you need here is `pipeline`.

Putting all those elements together, you can add this sample of code to achieve what you need by replacing the variables in all caps by the values you have:

var root = document.querySelector("#YOUR_SEARCH_INTERFACE_ID");
Coveo.$$(root).on("buildingQuery", function(e, args) {
    args.queryBuilder.pipeline = "YOUR_PIPELINE";
});

Hope this helps!

Gravatar for steven.leslie@mulesoft.com

Comment by Steven Leslie, Sep 13, 2018 7:55 PM

Thanks François! I'll give it a try.

Gravatar for wnijmeijer@coveo.com

Answer by Wim Nijmeijer, Sep 14, 2018 6:44 AM

Hi Steven,

If you create a search token, you could also set the pipeline in the searchtoken generation:

https://docs.coveo.com/en/56/cloud-v2-developers/search-token-authentication

Ask a question