MongoDB: Case-insensitive Index

Create

db.my_collection.createIndex({
    My_Field: 1
},{
    collation:{
        locale:   "en",
        strength: 1
    }
});

Notes

  • Use My Field: 1 to create ascending index values
  • Use locale to specific the language for case-insensitive ops, eg. check similarity between a A â
  • Use strength:1 to make small letter, capital letter, similar letter the same.

You'll only receive email when they publish something new.

More from 19411
All posts