Search With BuildFilter

Pa Njie
Member since: 1994


I am trying to search two fields using the BuildFilter extension method but no results are returned.  Here is the code I am using

var placeFilter = client.BuildFilter<Place>();

placeFilter = placeFilter.And(p => p.Name.MatchCaseInsensitive("Name"));
placeFilter = placeFilter.And(p => p.Locality.MatchCaseInsensitive("Locality"));

var place = _findClient.Search<Place>()

Running a search using either one of Name or Locality returns results, when used in an AND query nothing is returned.

Any help would be appreciated.


Apr 12, 2019 16:17
Bob Bolt
Member since: 2014

Hi Pa,  Are you using Epi Find?  If so, which version?

Apr 12, 2019 16:42
Pa Njie
Member since: 1994

Hey Bob,

Yes, I am using Episerver Find version 13.03.

Apr 12, 2019 16:47
Scott Reed
Member since: 2010

"using either one of Name or Locality" would suggest you should do an Or filter. An and will only match if both the values of Name AND Locaility match.

If it is an AND you can achieve that in one simple query using an & or even chaining filters as shown here

var place = _findClient.Search<Place>()
.Filter(p => p.Name.MatchCaseInsensitive("Name") & p.Name.MatchCaseInsensitive("Locality"))
Edited, Apr 15, 2019 15:29
Pa Njie
Member since: 1994

School boy error! I had a trailing blank space in my search criteria resulting in zero results being returned.

Apr 17, 2019 12:22