How to set mongoDB to be case insensitive as database or server level?

6,272 views
Skip to first unread message

Projapati

unread,
Apr 20, 2011, 7:39:13 PM4/20/11
to mongodb-user
I have a collection where each document has a tags array.
One document has tag=["lake"] while the other has tags=["Lake"]

Mongo is treating these tags as separate.

In SQL I can set up the database to be case insensitive.

How do I do that in mongo?

Otherwise, I will have lots of troubles.

Consider this simple case:
Some user signed up as "bob" and someone else can try to signup with
"Bob"
In reality I must treat username "Bob" already taken

I don't want to put case sensitivity parameters at query level. That
is naive.

Scott Hernandez

unread,
Apr 20, 2011, 7:40:48 PM4/20/11
to mongod...@googlegroups.com
MongoDB strings are case-sensitive. If you want them case insensitive
then always store them as lowercase and lowercase all query params.

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Projapati

unread,
Apr 20, 2011, 8:05:00 PM4/20/11
to mongodb-user
I would say this is a "severe" limitation in MongoDB. At least from
current SQL database perspective.

Now I will have to store 2 users names in users collection.
One to display and one to compare/query.
user: "blueeye", user_display:"BlueEye" since he would
love his name showing up as "BlueEye" not "blueeye"

Is there a future plan to have this as a database level option?

Scott Hernandez

unread,
Apr 20, 2011, 8:09:32 PM4/20/11
to mongod...@googlegroups.com
Yep, in the books here: https://jira.mongodb.org/browse/SERVER-90

I would suggest when you find an issue you search jira first. You
might be amazed at the information there; I am sometimes.

I find it useful to use google to search for me, using a site restriction.

Just type "site:jira.mongodb.org case insensitve" in at google; (see
how I made a type and it still worked)

Projapati

unread,
Apr 20, 2011, 8:20:59 PM4/20/11
to mongodb-user
That is a great relief. Thanks for the search tip. I will use it.
Reply all
Reply to author
Forward
0 new messages