單個查詢條件不區分大小寫
db.getCollection('test').find({test:{$regex:/xiao/i}}) 其中i表示不區分大小寫,/xiao/表示模糊查詢帶xiao的字段
db.getCollection('test').find({test:{$regex:/^xiao$/i}}) 加上^$是精確匹配,不是模糊匹配
數組的話也是這樣db.getCollection('test').find({test:{$in:[/shixiao/i]}})
單個查詢條件不區分大小寫
db.getCollection('test').find({test:{$regex:/xiao/i}}) 其中i表示不區分大小寫,/xiao/表示模糊查詢帶xiao的字段
db.getCollection('test').find({test:{$regex:/^xiao$/i}}) 加上^$是精確匹配,不是模糊匹配
數組的話也是這樣db.getCollection('test').find({test:{$in:[/shixiao/i]}})
【mongo 系列】mongodb 學習六,索引淺析 阿兵雲原生 2021-10-07 1,787 閱讀5分鐘 專欄: 開源組件專題