Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

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

$
0
0

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<string> SearchCategories
{
get
{
return Category.Select(x => x.ToString());
}
}

and I am registering it in my Initialization module as

SearchClient.Instance.Conventions.ForInstancesOf<BlogItemPage>().IncludeFiel
d(x => x.SearchCategories());

and on my controller (FindSearchPageController.cs)

var unifiedSearch =
SearchClient.Instance.UnifiedSearchFor(q).Skip(skipNumber).Take(pageSize).Fi
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.


Viewing all articles
Browse latest Browse all 6894

Trending Articles