Unfortunately, mongodb tends to be case sensitive in the kernel. You have several options:
1) Create a separate field that is a lowercase version of twitter_username and indexes it instead. Your object would have twitter_username and twitter_username_lc. Non-lowerecase, which you can use for display, etc., But lowercase, which you index and use in your where clause, etc.
This is the route that I have chosen for my application.
2) Create a really ugly regular expression from your username string in a loop before your search, and then pass it:
db.users.find({handle:{$regex: /^benhowdle89|^will shaver|^superman/i } })
Note that using βstarts withβ ^ carrots is best if the field is indexed.
source share