Try our conversational search powered by Generative AI!

Searching and Filtering Blocks

Vote:
 

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

#140212
Oct 13, 2015 12:14
Vote:
 

Hi,

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

#140271
Oct 14, 2015 16:07
Vote:
 

Hi Dejan,

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

Regards

#140272
Oct 14, 2015 16:29
Vote:
 

Hi,

Ted Nyberg wrote a blog post on how to add custom fields to the search index: http://tedgustaf.com/blog/2013/4/add-custom-fields-to-the-episerver-search-index-with-episerver-7/

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);



#140294
Oct 15, 2015 9:39
Vote:
 

Thank you Dejan!!

#140400
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.