Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

How does External Best Bets works

Vote:
 

Hello,

We have an implementation of Episerver Find (version 9.3.0.2674)  and our client wants to add Best bets for their sub domain links, which in turn I believe we have to use the External Link on Best bets. 

With Episerver Find we can successfully add the best bets for local and external link, when serching for Local from front end it returns the results, however when we tried to search those ones defined in external best bets, it does not return any values. All the time we have 0 Record count from the episerver find. 

Tried with after Indexing.

Analysing the index, we can see the ExternalBestBets in overview section of episerver find. Following is what it looks like in Index, there are no titles, search string, etc.,

{
    "___types": [
        "EPiServer.Find.Framework.BestBets.ExternalUrlBestBet",
        "System.Object"
    ],
    "$type": "EPiServer.Find.Framework.BestBets.ExternalUrlBestBet, EPiServer.Find.Framework",
    "Id$$string": "5097b23b-cd4f-49c4-8b83-d74fde6bfe84"
}

However, the local link search works fine.

Is this something an issue with episerver.find and if any one managed to make it to work.

Thanks,

Rams

#186080
Dec 11, 2017 19:29
Vote:
 

Can you post your query?

#186380
Dec 18, 2017 23:58
Vote:
 

Here is my code 

Below is my code to build findFilter

var findFilter = _client
                .BuildFilter<TResult>()
                .And(x => x.MatchTypeHierarchy(typeof(ISearchableContent)) & !(x as ISearchableContent).HideFromSearch.Match(true))
                .Or(x => x.MatchTypeHierarchy(typeof(ExternalUrlBestBet)));
var search = _client.UnifiedSearchFor(query)
                .Track()
                .Filter(findFilter)
                .Skip((page - 1) * itemsPerPage)
                .Take(itemsPerPage);

And the code to return results from search is 

var searchResult = search
                    .ApplyBestBets()
                    .Track()
                    .OverrideCurrentLanguage(Language.None)
                    .GetResult(new HitSpecification());

Thanks,

Rams

#186381
Dec 19, 2017 0:04
Vote:
 

I checked one of our sites and a ExternalBestBet looks like that in our index as well. Do you get the hit to show if you remove the .Filter() call?

#186393
Dec 19, 2017 9:04
Vote:
 

Thanks Johan, I get hits with filters on as shown on my code above, however the point it fails is when I am trying to convert the search Results into PageData, to get meaning information to display it on search page.

Here is my code 

var searchResult = search
                    .ApplyBestBets()
                    .Track()
                    .OverrideCurrentLanguage(Language.None)
                    .GetResult(new HitSpecification());

The above code returns hit, the point it fails is on below code

var results = searchResult
                    .Select(result => result.GetOriginalObject<TResult>())
                    .ToList();

Following is the implementation for GetOriginalObject which is an searchextension. For externalBestBet the OriginalObjectGetter is null, and hence it cannot find the Original Object.

public static T GetOriginalObject<T>(this UnifiedSearchHit hit)
        {
            if (hit.OriginalObjectGetter == null) 
                return default(T);

            var original = hit.OriginalObjectGetter.Invoke();

            if (original is T)
                return (T) original;

            return default(T);
        }

There is a bug raised for Original Object Getter being null , https://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=150369 on 2016, with no solution to it.

Any other thoughts would be greatly appreciated.

Thanks,

Rams

#186719
Jan 02, 2018 23:30
Vote:
 

I think an external best bet won't have an original object like that. At least it won't be convertible to PageData but probably just a minimal ISearchContent/UnifiedSearchHit.

#186868
Jan 08, 2018 9:23
Vote:
 

Thanks for that Johan, finally implemented with the minimal info from unifiedsearchhit resultset.

#186870
Jan 08, 2018 10:14
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.