c# - EpiServer Basic Filtering of Arbitrary Amount of Values -
consider following search:
return searchclient.instance.unifiedsearchfor(request.query) .filter(x => ((icontent)x).ancestors().match([ancestor id])) .getresult();
this works fine, long there 1 ancestor id
match with. there aren't, there multiple - i'm not sure of how many exactly.
how can perform multiple filters on result set?
what i've tried
var query = searchclient.instance.unifiedsearchfor(request.query); [ancestor ids].foreach(o => query.filter(x => ((icontent)x).ancestors().match(o.tostring()))); return query.skip(offset).getresult();
this doesn't appear work, filter isn't applied. assume that's because of way methods chained!?
any massively appreciated. bounty on table helps me crack it.
what else i've tried
var ancestorfilterbuilder = searchclient.instance.buildfilter<mypagetype>(); foreach (var ancestorid in ancestorids) { ancestorfilterbuilder.or(o => o.ancestors().match(ancestorid.tostring())); } ..... searchclient.instance.unifiedsearchfor(request.query) .filter(ancestorfilterbuilder)......
this didn't filter either.
i'd convinced myself i'd misunderstood episerver api, when in fact approach of dynamically building filter correct, aside reassigning of additional or
calls filter (inspired ted's reminder in context of other loop using):
var ancestorfilterbuilder = searchclient.instance.buildfilter<mypagetype>(); foreach (var ancestorid in ancestorids) { ancestorfilterbuilder = ancestorfilterbuilder.or(o => o.ancestors().match(ancestorid.tostring())); }
Comments
Post a Comment