Try our conversational search powered by Generative AI!

AsHighlighted returning empty instead of fragments.


I have a search page set up using Find (v11) w/ EPiServer 9.6.  For the most part, things are working as expected.  When we search, we project the different result types and one of the fields we select is the SearchText.AsHighlighted(), like follows:

search.Search(Language.English, x => x.For(s)
		.Select(p => new SiteContentResult {
			Link = p.ContentLink,
			Title = p.Title,
			Excerpt = p.SearchText().AsHighlighted(
				new HighlightSpec {
					FragmentSize = 100,
					NumberOfFragments = 3

In general, this works as expected, however for some queries, we get back results, but no fragments.  I read in the documentation here ( the following:

If there are no highlights for the requested field, the projected property is an empty string. To ensure that the property value is not empty, use an if statement.

Which seems to be what I am seeing.  However, it isn't clear (a) why there would not be highlighting when there are hits in the field, and (b) if there is any way to force the highlighting to occur.  

Looking at the documents in the index under the Find -> Overview -> Explore tab, I can see that the text being searched for does exist in the SearchText field (and the document wouldn't have been found in the first place if that wasn't the case).

Can someone explain why I'm seeing this result, and if there is a way to adjust the behavior so that I consistently get highlighted results?


Mar 01, 2016 16:12

Can't help you with why the fragments don't show up, but there's a not-well-documented extension that you can use to ensure to at least get an exerpt back if the highlighting fails; AddFallbackToBeginningOfHighlightedText

Edited, Mar 07, 2016 10:28
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.