`

mongodb like查询

阅读更多

假如需要查找的字符串为s,则可以用db.tables.find({"name":/s/}),或者db.tables.find({"name":/^s/}) ,或者db.tables.find({"name":/s.*/}),或者db.tables.find({"name":/.s.*/})

下面就分析下这几种查询的对应结果有什么不同:

1)db.city.find({"extra_data.region":/.新.*/})

共765条记录:包含了【高新技术。高新区,虎丘。渝北区(含北部新区)】

【注:由结果可以看出所查字符前面必须有字符,相当于:db.city.find({"extra_data.region":/.新./}),也相当于db.city.find({"extra_data.region":/.新/})】
-----------------------------------------------------------------------------------------------------------
2)db.city.find({"extra_data.region":/^新/})

共592条记录:包含了【新华。新洲。新都。新城。新区】

【注:由结果可以看出,此查询必须以所查字符开始】

-----------------------------------------------------------------------------------------------------------
3)db.city.find({"extra_data.region":/新.*/})

共1357条记录:记录包含了【新华。高新技术。渝北区(含北部新区)。高新区,虎丘】

【注:由结果可以看出前面字符可以有也可以没有,相当于:db.city.find({"extra_data.region":/新/})】

-----------------------------------------------------------------------------------------------------------

最后再分析下记录的结果,由上面三种查询可以看出,前两个查询的结果和正好等于最后一种的查询结果,这与注解完全符合。

---------------------------------------------------------------------------------------------------------------------------------

分享到:
评论

相关推荐

    Golang Mongodb模糊查询的使用示例

    主要给大家介绍了关于Golang Mongodb模糊查询的使用示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧

    Practical.MongoDB.Architecting.Developing.and.Administering.MongoDB

    It will prove equally useful for entrepreneurs and others who like to work with new technologies. Table of Contents Chapter 1: Big Data Chapter 2: NoSQL Chapter 3: Introducing MongoDB Chapter 4: The...

    在php7中MongoDB实现模糊查询的方法详解

    在实际开发中, 有不少的场景需要使用到模糊查询, MongoDB shell 模糊查询很简单: db.collection.find({'_id': /^5101/}) 上面这句就是查询_id以’5101’开始的内容。 在老的MogoDB中模糊查询挺简单的,这里简单...

    MongoDB模糊查询操作案例详解(类关系型数据库的 like 和 not like)

    主要介绍了MongoDB的模糊查询操作(类关系型数据库的 like 和 not like) ,本文通过代码案例分析给大家介绍的非常详细,具有一定的参考借鉴价值,,需要的朋友可以参考下

    java操作mongodb增删改查

    java操作mongodb增删改查mongodb查询 in like 修改自增

    Java操作mongodb的模糊查询和精确查询

    本意是想查查mongo数据库的int类型的like怎么查,但是好像没 解决这个问题。 精确查询;模糊查询;分页查询,每页多少:按某个字段排序(或升或降):查询数量:大于,小于,等于;且,或,某个字段不为空,某个字段不...

    MongoDB in Action

    Like Atlas, they go largely unnoticed in supporting the digital world we’ve come to inhabit. It’s easy to forget that our digital interactions, from commenting and tweeting to searching and sorting...

    Practical MongoDB 无水印破地方 0分

    Paperback: 249 pages Publisher: Apress; 1st ed. 2015 edition (December 16, 2015) Language: English ... It will prove equally useful for entrepreneurs and others who like to work with new tech

    MongoDB可视化界面 compass

    MongoDB的官方可视化界面 compass,下载了即可使用,界面简单好用

    PHP and MongoDB Web Development.pdf

    You will learn unique MongoDB features and solve interesting problems like real-time analytics, location-aware web apps etc. You will be guided to use MongoDB alongside MySQL to build a diverse data ...

    mongodb:学习mongodb

    会出现It looks like you are trying to access MongoDB over HTTP on the native driver port. 输入 mongo 出现connecting to:test 连接成功 show dbs 查看所有库 java来连接mongodb需要下载mongodb的驱动

    Build-Ecommerce-Website-Like-Amazon-React-Node-MongoDB:[Bassir Jafarzadeh]建立类似于Amazon的电子商务网站[React&Node&MongoDB] [ENG,2021年]

    $ cd Build-Ecommerce-Website-Like-Amazon-React-Node-MongoDB 2.设置MongoDB $ cd app/api $ docker-compose up 3.运行后端 $ npm install $ npm start 4.运行前端 $ cd client $ npm install

    Mongodb使用笔记

    It looks like you are trying to access MongoDB over HTTP on the native driver port.表示启动成功 5当mongod.exe被关闭时,mongo.exe 就无法连接到数据库了,因此每次想使用mongodb数据库都要开启mongod.exe程序...

    MongoDB数据库设计.pptx

    MongoDB is a document database, which means it stores data in JSON-like documents. We believe this is the most natural way to think about data, and is much more expressive and powerful than the ...

    MongoDB-Manual-master

    MongoDB is a document-oriented database management system designed ...If you’d like to learn how to use MongoDB with your programming language of choice, see the introduction to the drivers (page 393).

    MongoDB Basic

    NoSql DB,MongoDB is a cross-platform document-oriented database program. It is issued under the Server Side ... Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemata

    numactl-2.0.7 解决 mongodb 启动报警告的问题

    numactl-2.0.7 解决 mongodb 启动报警告的问题 *如果启动主服务报异常: ** WARNING: You are running on a machine. ** We suggest launching mongod like this to avoid performance problems: ** numactl --...

    记一次MongoDB性能问题(从MySQL迁移到MongoDB)

    公司为这个项目专门配备了几台高性能务器,清一色的双路四核超线程CPU,外加32G内存,运维人员安装好MongoDB后,就交我手里了,我习惯于在使用新服务器前先看看相关日志,了解一下基本情况,当我浏览MongoDB日志时,...

    Mongo_Manager_Pro_4.9.10.2.zip

    copy mongodbmanager.exe cracked file to install dir. After replace cracked file , register with any serial like : 123456789

Global site tag (gtag.js) - Google Analytics