如何在MongoDB指南针中查询您的数据,并使用案例不敏感的选项查询您的数据?

发布于 2025-02-13 06:33:27 字数 252 浏览 4 评论 0原文

我正在尝试使用中的$在多个值中查询MongoDB Compass GUI中的数据。

我的查询是 -

{category : {[$in: ['a012','b23c','5870T']}}

我想通过案例不敏感的选项i查询这些值。 中的操作员$也不接受根据文档接受正则表达式。

包括案例不敏感选项的正确查询是什么?

I am trying to query data in MongoDB compass GUI based on multiple values using $in.

My query is this -

{category : {[$in: ['a012','b23c','5870T']}}

I want to query these values with case insensitive option i. The operator $in also doesn't accept regex expressions as per documentation.

What would be the correct query with the case insensitive option included?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无尽的现实 2025-02-20 06:33:27

尝试以下操作:

db.mycollection.find({'category':{$in:[/a012/i, /b23c/i, /5870T/i]}})

多种方法:

  1. 为了限制字符串的“单词边界”,您可以使用\ b
db.mycollection.find({'category':{$in:[/\ba012\b/i, /\bb23c\b/i, /\b5870T\b/i]}})
  1. 使用m选项来匹配开始并结束字符串
db.mycollection.find({'category':{$in:[/a012/im, /b23c/im, /5870T/im]}})

Try this:

db.mycollection.find({'category':{$in:[/a012/i, /b23c/i, /5870T/i]}})

A couple of ways to do this:

  1. To limit to the 'word boundaries' of the string, you can use \b
db.mycollection.find({'category':{$in:[/\ba012\b/i, /\bb23c\b/i, /\b5870T\b/i]}})
  1. Use the m option to match the beginning and end of the string
db.mycollection.find({'category':{$in:[/a012/im, /b23c/im, /5870T/im]}})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文