We are using Episerver Find search functionality for our blogs. I have apage type (BlogItemPage) where we are displaying the category(usingEPiServer built-in category property) of the page.
I also want to search blogs on the basis of blog category. I am successfullyable 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 andstored in SearchCategories property. I have implemented the SearchCategoriesmethod 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 =
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 anysearch query enter by the user and if search query entered by user iscategory name it should display that blog results.
Any suggestions on how can I achieve this.
Something like this should work:
.Filter<BlogItemPage>(x => x.SearchCategories().Match(somecategory))
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.