Mongo在值中找到包含撇号的字符串

The field value contains a string with an apostrophe "Dreams I'll Never See" in the mongo collection field 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]);

This properly creates my record in my collection when one does not exist, and does not create several new ones when run again, however when I search for the title "Dreams I'll Never See" it doesn't find a match.

Example of my search code:

$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]
                ]
    );

I've googled all morning, but just can't seem to get this working correctly.

Mongo shell displays the record field stored:

"recording" : {
        "id" : "446ff065-a9bb-4171-a0d9-dbfa29661f99",
        "title" : "Dreams I’ll Never See",
        "score" : 100,
        "length" : 428000,
        "release-count" : 13
    },
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问