Is their any way to search a column in a collection in mongodb with $in which includes an array of elements for search and also caseInsensitive matching of those elements in the column ? N.B: I can use either Java-Mongodb or SpringMongodb Templete
Asked
Active
Viewed 708 times
1 Answers
0
You can try this with Spring Data Mongodb if you need one item of "yourArray" to match acase insensitive string:
query = new Query(Criteria.where("yourArray").regex(Pattern.compile("SEARCH", Pattern.CASE_INSENSITIVE)));
If you need "yourArray
elements to be in an array of case insensitive SEARCH
items, you would use $in
in MongoDB. Then, consider building a regex query string appending "|
" to each item, or build an AggregaationOperation
composed of one MatchOperation
for each item.

charlycou
- 1,778
- 13
- 37