Create filters in a non typed manner

Vote:
 

Hi,


Let's say we have facets that are quite dynamic that an editor can create by editing a field in EPiServer which makes it hard for us in the code.


I've made a model that holds all TermsFacets with TermCounts and which ones that are selected (by parsing the querystring) and each TermCount's url. Basically everything you need to render everything.

This makes it easy to bind the data to two nested repeaters, one for the TermFacets and the other one for the TermCounts. This makes it also easy to make it possible to select TermCounts from two different TermFacets, because all selected TermCounts is stored in the same querystring parameter prefixed with the name of the TermFacet.


The TermsFacets and TermCounts was easy to get hold off and parse. But when one TermCount (with its corresponding TermFacet) is selected how can I  add that term to the Filter with just a string representing the TermFacet and one one with the value?


I have a NameValuCollection (the Filter property in the code example below) where the key is the TermFacet and the values is the selected TermCounts.

foreach (var value in Filters.GetValues("SearchTypeName"))
{
    filter = filter.And(x => x.SearchTypeName().MatchCaseInsensitive(value));
}

In this case I have to know which property/method (SearchTypeName()) I want to filter by. Is it possible to do something like this!?

foreach (var key in Filters.AllKeys)
{
    filter = filter.And(CreateFilter(key).MatchCaseInsensitive(Filters[key]));
}

Hope all this makes sense...   

 

Hope all this makes sense...

#64321
Dec 17, 2012 21:36
Vote:
 

Oops some minor typos in the text above...


I guess I'm also looking for a TermsFacetFor() method which also takes string and not an expression, at least for ITypeSearch<TSource>.

 

First I was thinking of adding an extension method that returns a NameValueCollection which hold all the possible filters for all PageData objects and indexing it. And just filter by that method, BUT there is no DelegateFilterBuilder extension method that extends NameValueCollection.

#64322
Dec 17, 2012 21:49
Vote:
 

Hi Johan,

To make things a little clearer, could you post a bit more code, especially parts of the page type class that you're working with?

#64398
Dec 19, 2012 10:08
Vote:
 

Maybe I overshoot here a little bit. Found this project https://github.com/x2find/Dictionary2Find, and that suits my needs perfect.

I think a dictionary with metadata should be a part of UnifiedSearch, right built-in.

#64401
Dec 19, 2012 11:23
Vote:
 

Great! Guess you found this thread already? 

ISearchContent.SearchMetaData, although I believe you'll have to project whatever you need from it back :)

#64402
Dec 19, 2012 11:31
Vote:
 

Yeah of course you have to do that. But it's also a lot easier to build a nice global search page with multiple facets.

#64405
Dec 19, 2012 11:49
Vote:
 

Yeah. There's room for improvements in terms of facet handling in unified search.

#64406
Dec 19, 2012 11:55
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.