I have added the following snippet in a nest query which returns a ISearchResponse<T>
.Query(query => query.Match(m =>
m.Field(f =>
f => !string.IsNullOrEmpty(f.Purchase.NationalCode.Trim()))
)))
But it makes no difference to the amount of records returned (and I know there are nulls in there)
Should I do be building my query some other way?
Edited to add: I've tried the following based on this answer here but no luck either
.Query(query => query.Bool(b=>
b.Must(m=> m.Exists(
f=>f.Field("nationalCode")))))
.Query(query => query.Bool(b=>
b.MustNot(m=> m.Term(
"nationalCode", ""))))