2017-01-10

MongoDB - How to make a case insensitive query/filter

db.collection_name.find({
    "field_name": /^search_term_here/i
});

PS. Make sure to use "^" in order for the query to use the index, if available, to avoid a full scan.

No comments:

Post a Comment