Gravatar for joyceyurh@strateqgrp.com

Question by whyy, Aug 25, 2014 4:30 AM

[Closed] highlight searched text

How can I highlight the keyword that I searched for in the results returned with js platform?

For eg: i searched for "Panel", all the results returned with the word "panel" will be highlighted.

Thanks.

1 Reply
Gravatar for mlaporte@coveo.com

Answer by Martin Laporte, Aug 25, 2014 6:15 AM

You can do that for a couple of result fields when rendering the HTML from results. For example, in an Underscore template you can render the excerpts like this:

<%=highlight(excerpt, excerptHighlights)%>

This will cause keywords to be highlighted. You can do that with the title (title + titleHighlights), and a few other properties as well.

Gravatar for joyceyurh@strateqgrp.com

Comment by whyy, Aug 26, 2014 3:36 AM

possible to use it on customfields?

Gravatar for mlaporte@coveo.com

Comment by Martin Laporte, Aug 26, 2014 3:45 AM

No, as of now the index doesn't compute the highlight offsets for custom fields.

Ask a question