Searching and Filtering Blocks


I'm working in a search functionality, with the following elements:

1) I've a ShopPage, with a ShopContentArea that can contain only ShopBlocks (with name, address, region, state, etc)

2) I've a ShopResultsPage, where I need to get the ShopBlocks from ShopPages, filtering them with the value of some properties (search parameters: region/state), and display this ShopBlocks in a ShopContentArea in the ShopResultsPage.

I don't know how to develop such functionality in EpiServer 8 MVC. Basically the problem is that I'm not sure about:

- How get blocks from a content area of various ShopPages.

- How filter theses blocks.

- How to add the filtered blocks to a content area in the ShopResultspage. 

Any of you have suggestions on how to make it working???

Best Regards

Oct 13, 2015 12:14


Are you using EPiServer Find or standard EPiServer search based on Lucene.NET?

Oct 14, 2015 16:07

Hi Dejan,

I'm using standard EPiServer search based on Lucene.NET.


Oct 14, 2015 16:29


Ted Nyberg wrote a blog post on how to add custom fields to the search index:

You should index custom fields for region, state, etc.

And then you can get ShopBlocks like this:

var searchHandler = ServiceLocator.Current.GetInstance<SearchHandler>();

var query = new GroupQuery(LuceneOperator.AND);
query.QueryExpressions.Add(new ContentQuery<ShopBlock>());
// todo: filter by region, state, etc.

// return first 10 hits
var result = searchHandler.GetSearchResults(query, 1, 10);

Oct 15, 2015 9:39

Thank you Dejan!!

Oct 19, 2015 12:09
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.