MongoDB: Case-insensitive Index
August 20, 2023•57 words
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.