Using Coveo for Sitecore 4 and query suggestion using SearchBoxView. I need to modify the suggestion result item's url. Currently it performs a free text query when I click the suggestion. Instead I would like it to perform field-query (such as brand=<suggestion>).

I realize there are no js event available to work with this results like Omnibox. Is there any other way to do it?

  • 1
    Off-topic because it is not related to Sitecore, only Coveo. Feb 17, 2017 at 16:42
  • 1
    One would assume that Coveo for Sitecore would somehow be related to... Sitecore...
    – jammykam
    Feb 17, 2017 at 17:47

1 Answer 1


If I understand correctly, you want that when user clicks on a query suggestions, he gets redirected to the search page using a field query instead of a free-text search query.

You could try to add the OmniboxResultList component and use the onSelect event property. It defines a callback that is executed when you select an option. This would allow very powerful customization as you can also define your own result template with it.

However, if you want this behavior to also happen in the searchbox without clicking on a result, for example, when pressing Enter to execute the query, you should use the beforeRedirect event from the Omnibox component instead. Here is an example usage of this event:

var searchBoxElement = Coveo.$('#@Model.SearchboxId');
searchBoxElement.on(Coveo.StandaloneSearchInterfaceEvents.beforeRedirect, function(e, data) {
    // Get the current query and change it to a field query.
    var currentQuery = Coveo.state(searchBoxElement[0], "q");
    Coveo.state(searchBoxElement[0], "q", "@@YOUR_FIELD==\"" + currentQuery + "\"");

    // Execute the redirection as usual with the new state.
    var standaloneSearchInterface = Coveo.get(searchBoxElement[0], Coveo.SearchInterface);

(Inspired from here: https://answers.coveo.com/questions/8192/redirect-to-detail-page-rather-search-result-page)

  • Thanks for the answer. Tapping on to beforeRedirect doesn't seem to be a good fit for me. For 1, I do not always want to do field search but only when user selects a on suggestion. 2nd, for some reason, when do this the field query, it is being passed as url encoded causing the search to not match any result. I am not sure if I can use OmniResultList to display Suggestions. My suggestions are Field values and not items themselves. Ex: Suggestion is a Brand name field on Product template in sitecore. There is no specific Brand page or item unfortunately for me to use OmniResultList.
    – xoail
    Feb 21, 2017 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.