Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

UnifiedSearch excerpt length not constrained as expected.

$
0
0

We are indexing PDFs with Find. When we show the results, we display the title and the highlighted excerpt. The issue I am seeing is that the excerpt length doesn't seem to be respecting any of the limits we've passed in, so the excerpt is far too long.

In the search result template, we are rendering it using:

result.Document.Excerpt

In our Find Initialization, we are setting up the highlighted excerpt projection:

SearchClient.Instance.Conventions.UnifiedSearchRegistry.ForInstanceOf<MediaData>()
    .ProjectHighlightedExcerptUsing<MediaData>(spec => doc => !string.IsNullOrEmpty(doc.SearchAttachmentText().AsHighlighted()) ?
doc.SearchAttachmentText().AsHighlighted(new HighlightSpec() { FragmentSize = spec.ExcerptLength, NumberOfFragments = 1 })
: doc.SearchAttachmentText().AsCropped(spec.ExcerptLength));

When searching, we pass in a hit spec with highlighting enabled on the excerpt:

var hitSpec = new HitSpecification
			{
				HighlightExcerpt = true,
				EncodeTitle = false,
				EncodeExcerpt = false,
				ExcerptHighlightSpecAction = spec => new HighlightSpec { FragmentSize = 100, NumberOfFragments = 1, }
			};

What we see is that the excerpt comes back populated and highlighted, but the length appears to be the entire length of the AttachmentText rather than a truncated version of it per the hit spec or the highlight spec. 

I've adjusted the ProjectHighlightedExcerptUsing lamda, and the results change their excerpt correspondingly, so it is running / being called for the results I am looking at, but the length of the field just doesn't seem to be constrained.

Am I missing something?

Thanks!


Viewing all articles
Browse latest Browse all 6894

Trending Articles