Try our conversational search powered by Generative AI!

Search on the basis of category in unified Search ( Episerver Find )


We are using Episerver Find search functionality for our blogs. I have a
page type (BlogItemPage) where we are displaying the category(using
EPiServer built-in category property) of the page.

I also want to search blogs on the basis of blog category. I am successfully
able to search it on basis of any query entered by the user.

In find index in the admin view of the CMS, the category are index and
stored in SearchCategories property. I have implemented the SearchCategories
method on BlogItemPage.cs class as

public virtual IEnumerable SearchCategories




return Category.Select(x => x.ToString());



and I am registering it in my Initialization module as

d(x => x.SearchCategories());

and on my controller (FindSearchPageController.cs)

var unifiedSearch =
lter(x =>x.SearchCategories.Match(q));

model.Results = unifiedSearch.GetResult();

but the model.Results giving 0 hits for every category I search.

Also I want to provide both search option to user i.e. on the basis of any
search query enter by the user and if search query entered by user is
category name it should display that blog results.

Any suggestions on how can I achieve this.

Jul 27, 2017 10:28

Something like this should work:

.Filter<BlogItemPage>(x => x.SearchCategories().Match(somecategory))

Jul 31, 2017 8:41

Or actually, a better solution would be to just specify that you wish to search in the SearchCategories field:

.UnifiedSearch().For(q).UsingUnifiedWeights().InStandardFields().AndInField(x => x.SearchCategories)

You can remove your added convention and "SearchCategories" property that you added.

Jul 31, 2017 9:47
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.