Definition
New in version 8.2.
Note
The $encStrNormalizedEq
aggregation operator is only for encrypted fields in
collections with Queryable Encryption enabled. For
unencrypted fields, use Text Search operators to match
substrings.
$encStrNormalizedEq
Returns
true
if a normalized string value matches the normalized string version of the specified string. The queried field must have substring queries enabled, and the length of the query string must be between the configured minimum and maximum number of characters, inclusive.Note
This operator must operate on a text search index.
The
$encStrNormalizedEq
expression has the following operator expression syntax:{ $encStrNormalizedEq: <string> }
Behavior
Case sensitivity and diacritical mark sensitivity are determined by the configuration of the associated text search index.
Searches match whitespace characters.
Line breaks aren't considered when matching.
Tokenization delimiters aren't supported.
Example
Consider the character é, which can be represented two ways:
One code point,
U+00E9
(Latin small letter E with acute)Two code points,
U+0065
(Latin small letter E) followed byU+0301
(combining acute accent)
When comparing these two different representations of the name Béatrice:
Using
$eq
evaluates tofalse
, because the binary representations are different.Using
$encStrNormalizedEq
evaluates totrue
, regardless of thediacriticSensitive
setting, because the operator normalizes both strings prior to comparing them.
In mongosh
:
db.collection('MyCollection', function (err, collection) { collection.aggregate([ $match: { 'employeeLastName': { $encStrNormalizedEq: 'Béatrice' } }])