Explanation of Query Suggestions in a Search Box
Hi, I followed the tutorial on adding query suggestions to a search box. https://developers.coveo.com/display/public/SC201407/Add+Query+Suggestions+to+Your+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?
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:
- The field name in the "Auto Suggestion Keyword" template.
- 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:
- The template name.
- The template section name.
- The name of the facet bucket item.
- The value of the "Name" field of the facet bucket item.
- The name of the folder that stores the suggestion keywords.