Limit properties included in Excerpt returned from UnifiedSearchFor

Olov Nilzén
Member since: 2008
 

Is it possible to specify which properties that are included in the excerpt returned from UnifiedSearchFor?

Btw UnifiedSearchFor yields 0 results when searching at find.episerver.com, no docs available?

#65988 Feb 18, 2013 9:55
  •  

    http://find.episerver.com/Documentation/unified-search

    The cobbler's children go unshod

    #65996 Feb 18, 2013 11:54
  •  

    Now to your second question:

    The Excerpt by default will be either fieldvalues (from SearchSummary, SearchText, SearchAttachment) or highlighted fields (as the above) depending on the HitSpecification.HighlightExcerpt value passed to GetResult. So if you want to change the default you need to change either:

    // for field excerpts

    client.Conventions.UnifiedSearchRegistry
                     .CustomizeDefaultProjection(p =>
    
                         p.ProjectExcerptUsing<ISearchContent>(spec =>
                                 x => x.SearchTitle + " " + ..maybe another field value)
                     );

    // for highlights

    client.Conventions.UnifiedSearchRegistry
                    .CustomizeDefaultProjection(p =>
    p.ProjectHighlightedExcerptUsing<ISearchContent>(spec =>
                                x => x.SearchText.AsHighlighted(
                                    new HighlightSpec { FragmentSize = spec.ExcerptLength, NumberOfFragments = 1 }) + " " + ...maybe another highlighted field)
                    );   

    // to compile you currently also need the following extension

    public static HitProjectionBuilder ProjectExcerptUsing<T>(this HitProjectionBuilder builder, Func<HitSpecification, Expression<Func<T, string>>> sourceExpression)
            {
                return new HitProjectionBuilder(builder, projection => projection.ExcerptProjection = sourceExpression);
            }

    Edited: the excerpt will be either fieldvalues or highlighted values.

     

    /Henrik

    #66009 Edited, Feb 18, 2013 12:46
  • valdis iljuconoks
    Member since: 2011
     

    > Btw UnifiedSearchFor yields 0 results when searching at find.episerver.com, no docs available?

     

    I'm facing this case now. Any ideas what could be wrong and where to look for any hint?

    #71814 May 29, 2013 21:32
  •  
    #172191 Edited, Nov 25, 2016 13:14