botbotbot 's blog

Mongo Search

Regex

db.books.find({title: /สวัสดี/i}, {title: 1}).pretty()

For case sensitive regular expression queries, if an index exists for the field, then MongoDB matches the regular expression against the values in the index, which can be faster than a collection scan.

For case insensitive regular expression queries, these queries generally cannot use indexes effectively.

Fulltext search

db.books.ensureIndex({title:"text"})
db.books.reIndex()
db.bokks.find({$text:{$search:"time"}})