I'm having issue whereby i'm trying to query my mongo collection (called Projects) which contains an array. I have a query method which will check to see if the ListArray passed to method matches any of the entries in the mongo array. Now this works until there is a mismatch in the case sensitivity in the db.
I wont know if the values in the document are Upper or Lower case so I'd like to add a regex to ignore the case. However I can't figure out how to do it.
Here is the code for my query method:
@Override
public List<Project> findAllProjectsForShowCaseNewestFirst(Integer offset, Integer limit, List<String> techStack) {
Query query = new Query();
query.with(Sort.by(Sort.Direction.DESC, "createdDate"));
if(!techStack.isEmpty()) {
query.addCriteria(Criteria.where("projectTechStack").in(techStack));
}
return mongoTemplate.find(query, Project.class);
}
I've tried the following but it throws an error:
query.addCriteria(Criteria.where("projectTechStack").in(techStack).regex("i"));
I'd be very grateful if someone can help me here.
Thanks
Edit: its worth noting I can see how this works for a simple String as seen here BUT I can't for the life of me see how that would apply to a List