Gravatar for diego.moretto@xcentium.com

Question by Diego, Aug 15, 2016 12:03 PM

Coveo Field Suggestions on multiple fields. Is it possible?

hey folks

I have a CoveoFieldSuggestions configured to a single field which works fine like this:

<span class="CoveoFieldSuggestions" data-header-title="Suggested Results" data-field="@Model.ToCoveoFieldName("title")"></span>

Can I have the query suggest working with multiple fields instead with a single one(in this case 'title'')? Something like data-field="@Model.ToCoveoFieldName("title", "description", "summary")"?

If not how can I achieve something like that?

thanks

1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Aug 15, 2016 1:08 PM

Hi Diego,

The Coveo JavaScript Search Framework FieldSuggestions component doesn't support multiple fields for its field attribute as you can see in its documentation: https://developers.coveo.com/display/JsSearchV1/FieldSuggestions+Component

With this component, by default, the query box text is replaced by what was selected and a new query is executed from the suggested query. The basic use case is to suggest page titles or product names. Suggesting descriptions or summaries wouldn't help the visitors because those fields generally contains too much text for a search query to be useful.

If you have page titles spread across multiple fields, you could add multiple FieldSuggestions components on the same page like this:

<span class="CoveoFieldSuggestions" data-header-title="Suggested Queries" data-field="@Model.ToCoveoFieldName("title")"></span>
<span class="CoveoFieldSuggestions" data-header-title="Suggested Queries" data-field="@Model.ToCoveoFieldName("secondary title")"></span>

I hope this helps,

Jeff

Gravatar for diego.moretto@xcentium.com

Comment by Diego, Aug 15, 2016 5:58 PM

thanks Jeff!

Gravatar for diego.moretto@xcentium.com

Comment by Diego, Aug 16, 2016 1:06 PM

hey Jeff I have a scenario where there are fields that are not title but it is being asked that they show on the suggest. fiels like multiline and rich text. It´'s not ideal I know. the problem is if I add them I see on suggest html tags starting to show. do you know how can I strip those off the suggest? is there an easy way of doing that? thanks

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Aug 16, 2016 1:29 PM

Hi Diego,

I don't know any way to string the HTML of the field suggestions other than cleaning the value in a Sitecore Computed Index Field and using that field instead. You can use any .Net HTML parsing library.

From what you say, however, I would suggest results suggestions instead of query suggestions. Result suggestions with the Omnibox Result List component, would query all the free-text searchable information of the indexed documents (body, title, URI, free-text fields) to return results that can be clicked to navigate directly to the results.

Jeff

Gravatar for diego.moretto@xcentium.com

Comment by Diego, Aug 16, 2016 10:10 PM

ok thanks ;)

Ask a question