Gravatar for lautaro.bonetto@gmail.com

Question by Lautaro Bonetto, Aug 11, 2014 8:27 PM

How do I can add an autocomplete feature to the QueryBox component?

I'm using the Coveo JS Framework inside a Sitecore project. On the header of all the pages we have a search box (like an Standalone Search Box). The client is looking for an autocomplete feature on this search box. I've looked the OmniBox component, but it's too much. We need just an autocomplete feature.

Is there a way to add an autocomplete functionality to the QueryBox component easily?

Thanks for the help! Lautaro

1 Reply
Gravatar for mlaporte@coveo.com

Answer by Martin Laporte, Aug 12, 2014 3:54 AM

In itself the omnibox only displays content rendered by other components in a dropdown under the query box. What appears there (including auto-completions) depends on the other components in your search page.

What you are referring to as "too much" is probably the stuff added by the facets. You can disable that on a per-facet basis using the includeInOmniBox option on facets (https://developers.coveo.com/display/JsSearch/Facet+Component) . It's also possible to pass a default option for all facets at init time, see https://developers.coveo.com/display/JsSearch/jQuery+Extension .

To get classic auto-completions, you have the choice of using either https://developers.coveo.com/display/JsSearch/TopFieldSuggestions+Component or https://developers.coveo.com/display/JsSearch/TopAnalyticsSuggestions+Component . Those components, when present in the page, will display completions based either on the values of a field in the index or based on previous query history when usage analytics is enabled.

Then, if you want to use that outside of the main search page, take a look at the https://developers.coveo.com/display/JsSearch/Standalone+Search+Box page. It explains how to use a special feature of the JS UI to have it drive only a search box and redirect searches to your real search pages.

Gravatar for lautaro.bonetto@gmail.com

Comment by Lautaro Bonetto, Aug 12, 2014 10:23 AM

Thanks so much!

Ask a question