Try our conversational search powered by Generative AI!

Search With BuildFilter

Vote:
 

Hi,

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>()
    .Filter(placeFilter)
    .GetResult();

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.

Thanks

#203245
Apr 12, 2019 16:17
Vote:
 

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

#203246
Apr 12, 2019 16:42
Vote:
 

Hey Bob,

Yes, I am using Episerver Find version 13.03.

#203247
Apr 12, 2019 16:47
Vote:
 

"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 https://world.episerver.com/documentation/developer-guides/find/NET-Client-API/searching/Filtering/

var place = _findClient.Search<Place>()
.Filter(p => p.Name.MatchCaseInsensitive("Name") & p.Name.MatchCaseInsensitive("Locality"))
.GetResult();
#203281
Edited, Apr 15, 2019 15:29
Vote:
 

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

#203352
Apr 17, 2019 12:22
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.