I figured out that I had to add the following:
.IncludeType<ISearchResult, ExternalUrlBestBet>(x => searchResultFactory.Create(x, new BestBetRepository()))
Unfortunately I'm now stuck with another problem:
Unhandled exception in ASP.NET
EPiServer.Find.ProjectionException: An exception of type JsonSerializationException was thrown while deserializing object. ---> Newtonsoft.Json.JsonSerializationException: Error setting value to 'IsPendingPublish' on 'XYZ'. ---> EPiServer.Core.EPiServerException: Property 'PagePendingPublish' does not exist, can only assign values to existing properties
vid EPiServer.Core.ContentData.SetValue(String index, Object value)
vid Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value)
Try this:
Use SearchClient.Instance instead of Client.CreateFromConfig() if you using it and use GetContentResult() instead of GetResult()?
Old topic, but I think it is worth sharing.
You need to specify which properties you would like to fetch from the search engine in the projection.
.IncludeType<ISearchResult, ExternalUrlBestBet>(x => searchResultFactory.Create(x.Id, new BestBetRepository()))
Hi!
I have code somewhat similar to the following:
var result = _searchClient.Search(Language.Swedish)(x))(x))
.For(query)
.WithAndAsDefaultOperator()
.UsingSynonyms()
.ExcludeDeleted()
.FilterForVisitor()
.ApplyBestBets()
.Track()
.Filter(x => x.Ancestors().In(searchNodeIds))
.Skip(firstHit)
.Take(10)
.Select(x => searchResultFactory.Create(x))
.IncludeType
.IncludeType
.GetResult();
As you can see I've added ApplyBestBets. However, after reading the documentation (https://world.episerver.com/documentation/developer-guides/find/NET-Client-API/searching/Best-Bets/) I'm somewhat confused as to how I can get typed search to play well with Best Bets.
Can someone provide an example on how to work with Best Bets for typed search? Is it even possible or do I have use UnifiedSearch?
Any help would be appreciated!
EPiServer 10.10.4.0
Find 12.6.2.0
Searching CMS-content and some content pulled from outside the CMS