I am using a case insensitive search in Mongo, something similar to https://stackoverflow.com/q/5500823/1028488.
ie I am using a regex with options i. But I am am ha
Use $strcasecmp. The aggregation framework was introduced in MongoDB 2.2. You can use the string operator "$strcasecmp" to make a case-insensitive comparison between strings. It's more recommended and easier than using regex.
Here's the official document on the aggregation command operator: https://docs.mongodb.com/manual/reference/operator/aggregation/strcasecmp/#exp._S_strcasecmp .