i am writing a spring boot mongo query to fetch the results based name, csi, city. sometimes name, csi is empty in that case my query should not consider the fields which are empty. query should exclude the fields and incase data is there it suppose to fetch the results.
For Example
$match:{
name:'test',
csi:'' //exclude if blank or null,
city:'hyd'
}
my springboot query is but it is not ignoring the fields when empty
@Aggregation({
"{\"$match\": { \"$and\" : [ {\"name\" : { \"$ne\":\"\" }}, {\"name\" : ?0 }, {\"csi\" : { \"$ne\":\"\" }}, {\"csi\" : ?1 }, {\"city\" : { \"$ne\":\"\" }}, {\"city\" : ?2 }] }}"
})
List<data> getdata(String name, String csi, String city);