Try our conversational search powered by Generative AI!

Problem with getresult() in a multiSearch()

Vote:
 

Hi all,

I have problem with that getresult() is throwing an exeption when doing a multisearch in EPIServer FIND 9.


Exeption:

-InnerException{"Error setting value to 'IsPendingPublish' on 'sokjamfor.Models.Pages.EducationEventPage'."}System.Exception {Newtonsoft.Json.JsonSerializationException}

Code:

var searchResults = SearchClient.Instance.MultiSearch()
   .Search(x => x.For("a").InField(y => y.SearchableDescription))
   .GetResult();

public class EducationEventPage : SearchablePageData
{

public virtual String Identifier { get; set; }


public virtual String Education { get; set; }


public virtual ContentReference EducationRef { get; set; }


public virtual String Provider { get; set; }

....

}

public class SearchablePageData : PageData
{

...


public virtual String SearchableDistance { get; set; } 

public virtual String SearchableDescription { get; set; }

...

}

I have tested to do a get() to retrieve the content from the cms as work around suggested in this thread:

http://world.episerver.com/Modules/Forum/Pages/thread.aspx?id=85490

Code:

var searchResults = SearchClient.Instance.MultiSearch()
 .Search(x => x.For("a").InField(y => y.SearchableDescription)
.Select(y => contentRepository.Get(((IContent)y).ContentLink)))
.GetResult();

But i can't seem to get it to compile

Error103Cannot implicitly convert type 'EPiServer.Find.ISearch' to 'EPiServer.Find.ITypeSearch'. An explicit conversion exists (are you missing a cast?)C:\Users\maer0216\documents\visual studio 2012\Projects\sokjamfor\sokjamfor\Services\SearchService.cs18322sokjamfor

Any help in the matter is highly appreciated!

Magnus

#121393
May 08, 2015 13:01
Vote:
 

What happens if you do like this?

var searchResults = SearchClient.Instance.MultiSearch<EducationEventPage>()
   .Search<EducationEventPage>(x => x.For("a").InField(y => y.SearchableDescription))
   .GetContentResult();
#121399
May 08, 2015 15:08
Vote:
 

Then i get a build error; It seems like multisearch does not support GetContentResult()

Error103'EPiServer.Find.IMultiSearch<sokjamfor.Models.Pages.EducationEventPage>' does not contain a definition for 'GetContentResult' and no extension method 'GetContentResult' accepting a first argument of type 'EPiServer.Find.IMultiSearch<sokjamfor.Models.Pages.EducationEventPage>' could be found (are you missing a using directive or an assembly reference?)C:\Users\maer0216\documents\visual studio 2012\Projects\sokjamfor\sokjamfor\Services\SearchService.cs1824sokjamfor

#121402
May 08, 2015 15:11
Vote:
 

Ok. I have not used multi search so mutch so I was not shore if it would work.

In that case I would try to change to return only the id of the content and then do thing with IContentRepository on the returned list before returning it to the page requesting the search.

Meaning moving that part to after getresult.

#121403
May 08, 2015 15:34
Vote:
 

ok, that might work (if manage to write the code :)). But then we have the next problem. The code that I put as example in this thread is not the complete use case. What I really want to fetch from find is the facets for a specifick property:

var searchResults = SearchClient.Instance.MultiSearch<EducationEventPage>()
.Search<EducationEventPage>(y => y.TermsFacetFor(x => x.SearchableProvider, facet => facet.Size = 200)
  .Filter(filterProvider) //Filter each of the categories so that we get only the ones we want
  .Take(1));

Is it possible to achivie this without using FIND?

Magnus

#121450
May 11, 2015 15:34
* 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.