Get Title and Excerpt when applied Best Bets to a Typed Search?

Vote:
 

I have applied best bets to the Typed search as the Episerver developer documentation stated it. Is there a way to get the Best bet Title and the Excerpt (which are defined in the best bet edit mode in Epi Admin).

My implementation as of now,

// Sample Pages are stored in the Find Index
public class SamplePage : EPiServer.Core.PageData
    {
        public string SamplePageTitle { get; set; }
        public string SamplePageDescription { get; set; }
    }
public class SearchResult
    {
        public string Title { get; set; }
        public string Description { get; set; }
    }
// Getting the results
var result = client.Search<SamplePage>(GetLanguage(LanguageID))
                .For(Query, SearchHelper.QueryStringQueryAction)
                .Select(x => new SearchResult
                {
                    Title = x.SamplePageTitle, // Any way to have the Best Bet title ?
                    Description = x.SamplePageDescription // Any way to have the Best Bet Excerpt?
                })
                .ApplyBestBets()
                .Take(PageSize).GetResult();

As I have mentioned above, is there a way to get the Title and Excerpt?

Thanks.

#215900
Jan 17, 2020 5:03
Vote:
 

Hi guys, just realized nobody replied on this post. Does anybody know a fix for this issue?

#218059
Mar 05, 2020 6:23
Vote:
 

Hi Senura,

I believe you'll need to use UnifiedSearch. Once you're using that, the results will be of the type 'UnifiedSearchHit' and then the document on them will have the Title and Excerpt automatically.

i.e.

var unifiedSearch = _client.UnifiedSearch()
    .For(query)
    .ApplyBestBets()
    .GetResult();

var excerpt = unifiedSearch.Hits.First().Document.Excerpt;
var title = unifiedSearch.Hits.First().Document.Title;

Cheers,

- JJ

#218065
Mar 05, 2020 9:13
Vote:
 

@James Johnson, I appreciate your answer. However, isn't there a way to get the best bet title and excerpt using the ITypeSearch (Typed Search) ? Because the current search implementation is heavily configured with the ITypeSearch and moving to UnifiedSearch is not worth.

I am wondering why Episerver documentation has stated we could apply best bets to the typed search. What's the purpose of mentioning that in the documentation if we could not get the title and excerpt using the Typed Search ?

#218066
Edited, Mar 05, 2020 9:23
Vote:
 

Hi Senura,

You can apply the best bets to typed searches but as far as I'm aware, the results are more or less bundled in together, versus the unified search which has more data on if the result is a best bet or not.

Given the lack of other responses, you might be better off submitting a support ticket to support@episerver.com to try and find out directly from them if it is possible or not...?

Should it not be available for typed search, I think you'd need to do something like querying the 'BestBetRepository' and finding the one(s) that match your query phrase, then grabbing the Title and Excerpt from there.

Cheers.

- JJ

#218069
Mar 05, 2020 10:16
* 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.