Definition
New in version 8.2.
Note
The $encStrEndsWith
aggregation operator is only for encrypted fields in
collections with Queryable Encryption enabled. For
unencrypted fields, use Text Search operators to match
substrings.
$encStrEndsWith
Returns
true
if the last characters of a string value match the characters in the specified string. The queried field must have suffix queries enabled, and the length of the query string must be between the configured minimum and maximum number of characters, inclusive.By default, strings must match case and diacritical marks.
Set
caseSensitive
tofalse
in the encryption schema for case-insensitive matching.Set
diacriticSensitive
tofalse
in the encryption schema to disregard diacritic variations when matching.
The
$encStrEndsWith
expression has the following operator expression syntax:{ $encStrEndsWith: <string> }
Behavior
Searches match whitespace characters.
Line breaks aren't considered when matching.
Tokenization delimiters aren't supported.
Example
In mongosh
:
db.collection('MyCollection', function (err, collection) { collection.aggregate([ $match: { 'employeeFirstName': { $encStrEndsWith: 'son' } }])