Add Dynamic Query Suggestions to Your Search Box in Coveo JS Framework

Posted 08/05/2014 by Akshay Sura

In almost every search implementation we had to add an auto suggestions for the search box. This job is made easy by using the Coveo JS Framework. You can achieve the basic functionality using the article found HERE.

But in most cases you do not want a set list of auto suggestions, rather you would want it to use the index to pull the list. Below is a standard implementation where we are pulling results from a Sitecore folder.

In order for us to make this a bit more dynamic, we need to identify the template or templates we want the results to come from, along with the field or fields which need to be searched. As an example, lets say we have a Product template with a field Product Name. When a user starts typing in to a product finder, we would like to search the index for all items which are based on the Product Template and we would match the search string against the Product Name field.

In the above example, we are setting the template field to find Product Template and in the html markup we are are asking for Coveo to search in the Product Name field. 

All of this works great. But if you add in a multi-lingual website and want results from multiple templates and fields, here is how you do it:

Fields used for auto suggestions have to be setup as Facets.

Let me know if you have any questions or comments.