I'm generating a complicated Mongo
query depending on multiple parameters. One of criterion that I want to make with Criteria
helper class is:
{"field1": {$exists: true, $ne: false}}
I tried to make it with:
Criteria.where("field1").is(Criteria.where("$ne").is(false).and("$exists").is(true))
But it generates:
{ "field1" : { $java : org.springframework.data.mongodb.core.query.Criteria@23864e60 }
So, how to achieve the exact query that i need?
I can't hardcode that query string, because these type criterions are generated dynamically for field1,...fieldN and then combined with $or
:
statusCriteria = statusCriteria.orOperator(criterias.toArray(new Criteria[criterias.size()]));