How to write this query in java.
db.getCollection('recipe_qmeshm_enumerations').find({
"values.value":/^\QbuTTer\E$/i
})
I am trying to write like this but it's not giving any result.
Criteria criteria2 = new Criteria().where("values.value").regex("/^\QbuTTer\E$/i");
Query query2 = new Query();
query2.addCriteria(criteria2);
I am able to create the query by myself. The above query could be written as
db.getCollection('recipe_qmeshm_enumerations').find({
"values.value":/^Ice cream$/i
})
and in java,
String searchValue = "ice cream";
Criteria criteria2 = new Criteria().where("values.value").regex("^"+searchValue+"$","i");
Query query2 = new Query();
query2.addCriteria(criteria2);
List<Document> enumsDoc = mongoAddonsTemplate.find(query2, Document.class, indexName);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.