Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

HitSpecification - Logic used for constructing the excerpt text


Im a little confused about how the HitSpecification chooses which properties to use for building the excerpt text for a result.

I have created a custom projection for the excerpt text from for the pages on my site:

                .ProjectExcerptUsing<SitePageBase>(spec =>
                            x => x.TeaserText);

This correctly displays teaser text when available on the page, however it seems when the teaser text is not long enough to fill the ExcerptLength defined on the HitSpecification, it will get text from other properties on the page to makeup the length.

I would like to either:

  1. Insutrct the HitSpecification to not use any other properties other than the one defined in the projection (even if it falls short in length)
  2. or.. Define the fallback properties to use in the event the teaser text falls short? (i.e MainBody)




Jun 17, 2013 16:27

Your snippet looks correct and should work as expected (your excerpt should only contain TeserText). I've not been able to recreate the issue. Can you post the exact query you are performing? 

Jun 19, 2013 14:17


If you check the EPiServer.Find.UnifiedSearch.HitProjection.GetProjection method, you will  see the logic used when getting Excerpt text like below:

 Expression expression2 = hitSpecification.HighlightExcerpt ? HitProjection.ReplaceParameter(this.HighlightedExcerptProjection(hitSpecification), newParameter).Body : HitProjection.ReplaceParameter(this.ExcerptProjection(hitSpecification), newParameter).Body;
 MemberAssignment memberAssignment2 = Expression.Bind((MemberInfo) typeof (UnifiedSearchHit).GetProperty("Excerpt"), expression2);

So you can choose one of below ways to make your customization works:

  1. Override HitSpecification with HighlightExcerpt as true (see more here
  2. Add the customization for ProjectHighlightedExcerptUsing  as below
                .ProjectExcerptUsing<CorporateContentPage>(spec => x => x.TeaserText);
                .ProjectHighlightedExcerptUsing<CorporateContentPage>(spec => x => x.TeaserText);

Hope it helps :)

Edited, Feb 28, 2022 4:51
* 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.