volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Search categories with EPiServer Find

Hi!

I'm currently in a project where they use EPiServer Find and unfortunately I haven't used it before so I'm kind of lost.

At the moment you can only search for pages by Text and Title:

var findClient = Client.CreateFromConfig();

var queryObject = findClient.Search<SitePageData>()
.For(query)
.WildCardQuery(String.Format("{0}*", query), x => x.SearchText())
.WildCardQuery(String.Format("{0}*", query), x => x.SearchTitle())


After this code there are some filtering done aswell but that is irrelevant.

What I want to do now is to be able to get hits on the categories of the page also.

I tried something like this:

.WildCardQuery(String.Format("{0}*", query), x => x.SearchCategories()) but it want a string and not an IEnumerable. So I tried this:


.WildCardQuery(String.Format("{0}*", query), x => ConvertCategoriesToString(x.SearchCategories())). It compiles but doesn't work.

I also tried using "InField" like they do here: http://find.episerver.com/Documentation/dotnet-api-searching

but it still doesnt work with categories, only simple strings. 

I think I'm not approaching this correct at all...

Some help would be very nice :)

#86921
Jun 04, 2014 12:03

Doh, now I feel stupid. It actually worked all along... 

I had to write the entire category string in the search query to get a hit (of course). I got confused by the wild card queries for Text and Title where you dont need to write the entire title or text to get a hit (of course).

#86925
Jun 04, 2014 12:52
* 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.