mongodb - 带有 & 的 MongoDB 搜索查询
问题描述
我的文档具有如下所示的结构。
{
id: '2eacea29-915c-4573-91c3-98815143b722',
name: 'hey look at all this &'
}
我已经尝试执行搜索查询db.myCollection.find({"$text" : {"$search" : "\"\&\""}})
。但结果为空。怎么了?
解决方案
尝试使用$regex
.
db.collection.find({
"name": {
"$regex": "&"
}
})
推荐阅读
- c# - 3 个实体之间的三元关系导致实体框架“可能导致循环或多个级联路径”错误
- django - Heroku - 设置 Procfile 以运行 Django 命令来创建数据库
- c - 是否有将 Racket 编译为 C 的编译器?
- android - ProGuard 错误:文件 'C:\...\proguard.txt' 第 16 行中的未知选项 '-if'
- php - 如何创建时间范围列表?
- java - Intellij IDEA 无法识别 java 文件:目录中有蓝色方块
- php - 在 URL 中插入引号
- python - 如何从 Excel 工作表中的单元格中删除或忽略控制字符 \r 或“”?
- mql5 - 编写止损处理程序
- sql-server - 如何在 SQL 连接字符串中使用 Azure KeyVault 机密?