Gravatar for

Question by debubiswas, Feb 25, 2015 2:31 AM

Excerpt not always show the keyword searched for

Using coveo for sitecore, my expectation was with the search results there will be excerpts that would display containing the keyword I searched for. This is not happening most of the time. Please help.

3 Replies
Gravatar for

Answer by debubiswas, Feb 26, 2015 5:38 AM

Thanks all for the answers. I was informed by coveo support that the excerpts even if displayed would not be always showing the keyword you searched for. It is not designed that way. So I found a more robust and controlled way of doing this. I defined my own custom processor that filled a custom field of mine with values from all sitecore fields that I want the free text search to find value at.

Now instead of earlier default way of showing the excerpt as

{{=highlight(excerpt, excerptHighlights)}}

I now had the line replaced with

{{=Coveo_GetExcerpt(raw.<%=ToCoveoFieldName("[my custom field]", false) %>)}}

In the js function "Coveo_GetExcerpt" I then made sure to search and display the line with keyword that I searched for. So all good then.

Gravatar for

Answer by Martin Laporte, Feb 25, 2015 3:25 AM

Excerpts are extracted from each document's body. No excerpt typically means that your documents have no body (e.g. they only have fields). This is configured at indexing time. I'm not sure about the Sitecore specifics, though, some others may have a more precise answer regarding that part.

Gravatar for

Comment by debubiswas, Feb 25, 2015 3:30 AM

If there is a match found on my searchable coveo fields, only then do I see the results. I am confused about excerpts if they are calculated during indexing, because excerpts or" something else that represents keywords searched for within a coveo document" needs to show dynamically.

Gravatar for

Comment by Martin Laporte, Feb 25, 2015 3:34 AM

Excerpts are dynamically computed at query time using as raw material the "body" content of each result. They do not include content put in custom fields (e.g. @something), only what has been defined as the main body.

For example, for a PDF document the body is the content extracted by the PDF converter. For structured data we depend on the fact that some content is identified as "the body" at indexing time. There is certainly a simple way to do that in the Sitecore integration, but I'm not working on that team so I can't help much --- others might later on.

Gravatar for

Answer by Jean-François L'Heureux, Feb 25, 2015 1:47 PM

Like mlaporte said, the reason you don't have excerpts is probably that your indexed documents don't have a body. By default, Coveo for Sitecore puts the _content field value in the indexed document body. You can choose what goes in the indexed document body by using the BasicHtmlContentInBodyProcessor (see Indexing Documents with Basic HTML Content) or the HtmlContentInBodyWithRequestsProcessor (see Indexing Documents with HTML Content Processor).

Ask a question