php - Mongo查找值中包含撇号的字符串
问题描述
字段值在 mongo 集合字段中包含一个带有撇号“Dreams I'll Never See”的字符串recording.title
$updateResult = $collection->findOneAndUpdate(
[
'recording-id' => $out['recording']->id
],
['$set' => [
'recording' => [
'id' => $out['recording']->id,
'title' => $out['recording']->title,
'score' => $out['recording']->score,
'length' => $out['recording']->length,
'release-count' => count($out['recording']->releases)
]
],
['upsert' => true]);
当一个不存在时,这会在我的集合中正确创建我的记录,并且在再次运行时不会创建几个新记录,但是当我搜索标题“我永远不会看到的梦想”时,它找不到匹配项。
我的搜索代码示例:
$t = "Dreams I'll Never See";
$a = "Molly Hatchet";
$cursor = $collection->find(
['$and' => [
[ 'recording.title' => $t ],
[ 'artist.name' => $a ]
]
],
['projection' => [
'recording' =>1,
'release' =>1,
'artist' =>1,
'release-group' =>1
],
['limit' => 1]
]
);
我整个早上都在谷歌上搜索,但似乎无法正常工作。
Mongo shell 显示存储的记录字段:
"recording" : {
"id" : "446ff065-a9bb-4171-a0d9-dbfa29661f99",
"title" : "Dreams I’ll Never See",
"score" : 100,
"length" : 428000,
"release-count" : 13
},
解决方案
推荐阅读
- javascript - React-Native:通过单击按钮加载屏幕
- validation - 三维向量的 z 分量
- spring-boot - Spring session,控制台消息解读
- oracle - 调用函数时出现“java.sql.SQLException:索引处缺少 IN 或 OUT 参数:: 1”
- python - 锁定窗口一次后,Python 键盘模块 add_hotkey 不起作用。需要帮助
- c# - 是什么导致材料闪烁?
- ruby - 将句子的每个单词转换为字符串(Ruby on Rails)
- amazon-web-services - 仅在具有特定标签的资源上允许 iam:UpdateUser
- neo4j - Neo4j - Flight Analyzer - 2 个问题
- java - files.get() 方法是否受 Java 中文件大小的影响?