Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/
Database Manual
/ / /

$encStrStartsWith (encrypted aggregation operator)

New in version 8.2.

Note

The $encStrStartsWith aggregation operator is only for encrypted fields in collections with Queryable Encryption enabled. For unencrypted fields, use Text Search operators to match substrings.

$encStrStartsWith

Returns true if the first characters of a string value match the specified string. The queried field must have prefix 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 to false in the encryption schema for case-insensitive matching.

  • Set diacriticSensitive to false in the encryption schema to disregard diacritic variations when matching.

The $encStrStartsWith expression has the following operator expression syntax:

{ $encStrStartsWith: <string> }
  • Searches match whitespace characters.

  • Line breaks aren't considered when matching.

  • Tokenization delimiters aren't supported.

In mongosh:

db.collection('MyCollection', function (err, collection) {
collection.aggregate([
$match: {
'employeeFirstName': { $encStrStartsWith: 'Sam' }
}])

Back

$encStrNormalizedEq

On this page