Gravatar for

Question by sholmesby, Jun 25, 2015 12:23 PM

Explanation of Query Suggestions in a Search Box

Hi, I followed the tutorial on adding query suggestions to a search box.

At one stage, I magically had this working, but went to rename some items and everything broke. I tried to revert my items, and still the query suggestions aren't showing up.

It's difficult to figure out this issue because in the tutorial, the template name, field name, facet name and folder name are all the same (field name actually has a typo though). And with all of these named the same, the code

<%= Coveo.UI.SitecoreUtilities.ToCoveoFieldName("Auto Suggestion Keyword") %>

also matches the same name. ("Auto Suggestion Keyword").

Can someone explain to me what this code is actually trying to match? Do all the items, fields etc need to be the same?

And also, even though I re-named them all back… does anyone have any idea why this is no longer working for me?

Update: I found that the code is outputting 'fautoz32xsuggestionz32xkeyword91555', but the index field name in CES is 'fautoz32xsuggestionz32xkeyword40212'.

Any idea why the hash is different?


1 Reply
Gravatar for

Answer by Jean-François L'Heureux, Jun 26, 2015 1:22 PM

Hi Sean,

The field name hash for the queries is determined by the current Sitecore context database. If you open your page in the Page Editor in edit or preview mode, the database will likely be "master" and Coveo for Sitecore will use the hash of the first Coveo index that indexes the "master" database. However, if you open your page on the published site, the database will likely be "web" and Coveo for Sitecore will do the same job to select an index indexing the "web" database.

Is it possible that you didn't look in the right field set/source in CES when looking for the field?

For the "Auto Suggestion Keyword" confusion, I agree that the documentation is indeed confusing. To work correctly, the "Auto Suggestion Keyword" in <%= Coveo.UI.SitecoreUtilities.ToCoveoFieldName("Auto Suggestion Keyword") %> should match:

  1. The field name in the "Auto Suggestion Keyword" template.
  2. The value of the "Field Name" field in the "Auto Suggestion Keyword" facet bucket item.

All the other names can be changed and be unique if you want:

  1. The template name.
  2. The template section name.
  3. The name of the facet bucket item.
  4. The value of the "Name" field of the facet bucket item.
  5. The name of the folder that stores the suggestion keywords.
Gravatar for

Comment by sholmesby, Jun 26, 2015 1:44 PM

Perfect, thanks for the explanation.

Ask a question