November Happy Hour will be moved to Thursday December 5th.

Multiple match DelegateFilterBuilder

Vote:
 

Hi,

I need to find content where multiple categories are set.

In this code I want to find all SitePageData where Category is 2 AND 3. I thought the DelegateFilterBuilder "In" would help me with this but it seem to handle it as 2 OR 3.

Is there some smart way to do this?

var categoryIds = new List<int> { 2, 3 };
var result = SearchClient.Instance.Search<SitePageData>()
.Filter(c => c.Category.In(categoryIds))
.GetContentResult();

Thanks!

#87064
Jun 09, 2014 14:53
Vote:
 
var query = SearchCilent.Instance.Search<SitePageData>();
var catalogBuilder = searchInstance.BuildFilter<SitePageData>();
foreach (int category in categoryIds)
	catalogBuilder = catalogBuilder.And(x => x.Category.Match(category));

result = query.Filter(catalogBuilder).GetContentResult;

Think something like that should do the trick.

#87066
Jun 09, 2014 14:57
Vote:
 

It sure did!

Thanks!

#87104
Jun 10, 2014 9:15
Vote:
 
#87111
Jun 10, 2014 9:52
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.