AWS Security ChangesHomeSearch

AWS documentdb documentation change

Service: documentdb · 2026-03-31 · Documentation low

File: documentdb/latest/developerguide/regexFind.md

Summary

Added new documentation page for the $regexFind operator in Amazon DocumentDB, including syntax, parameters, examples in MongoDB Shell, Node.js, and Python, and notes about Elastic cluster support and query planner requirements.

Security assessment

This change documents a new MongoDB aggregation operator ($regexFind) for regular expression matching. There is no evidence of addressing a security vulnerability, weakness, or incident. The documentation includes standard connection examples with TLS parameters (tls=true, tlsCAFile) which are security best practices but not new security features. The note about using hints to avoid collection scans is performance-related, not security-related.

Diff

diff --git a/documentdb/latest/developerguide/regexFind.md b/documentdb/latest/developerguide/regexFind.md
index 8b1378917..51e47c8e1 100644
--- a//documentdb/latest/developerguide/regexFind.md
+++ b//documentdb/latest/developerguide/regexFind.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#regexFind "Open PDF")
@@ -1,0 +3,130 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $regexFind
+
+New from version 5.0.
+
+Not supported by Elastic cluster.
+
+The `$regexFind` operator in Amazon DocumentDB is used to perform regular expression matching on string fields within documents. It allows you to search for and extract specific substrings that match a given regular expression pattern.
+
+**Parameters**
+
+  * `input`: The string field or expression to search.
+
+  * `regex`: The regular expression pattern to match.
+
+  * `options`: (optional) An object that specifies optional parameters for the regular expression, such as case-sensitivity and multi-line matching. Supported options are `i` (case-insensitive) and `m` (multi-line).
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$regexFind` operator to search for documents where the `name` field matches a specific regular expression pattern.
+
+**Create sample documents**
+    
+    
+    db.users.insertMany([
+      { "_id": 1, name: "John Doe", email: "[email protected]" },
+      { "_id": 2, name: "Diego Ramirez", email: "[email protected]" },
+      { "_id": 3, name: "Alejandro Rosalez", email: "[email protected]" },
+      { "_id": 4, name: "Shirley Rodriguez", email: "[email protected]" }
+    ]);
+
+**Query example**
+    
+    
+    db.users.aggregate([
+      {
+        $project: {
+          names: {
+            $regexFind: { input: '$name', regex: 'j', options: 'i' }
+          }
+        }
+      },
+      { $match: {names: {$ne: null}}}
+    ])
+
+This query will return all documents where the `name` field contains the letter "j" (case-insensitive).
+
+**Output**
+    
+    
+    [
+      { _id: 1, names: { match: 'J', idx: 0, captures: [] } }
+    ]
+
+**Note:** If your query is using Amazon DocumentDB planner version 1, you must use a hint to utilize an index. Without a hint, the query may perform a collection scan. To check your planner version and learn more about using hints, see the [Amazon DocumentDB Query Planner documentation](https://docs.aws.amazon.com/documentdb/latest/developerguide/query-planner.html).
+
+## Code examples
+
+To view a code example for using the `$regexFind` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function main() {
+      const client = await MongoClient.connect('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false');
+      const db = client.db('test');
+      const users = db.collection('users');
+    
+      const results = await users.aggregate([
+        { $project: { names: { $regexFind: { input: "$name", regex: "john", options: "i" }}}},
+        { $match: {names: {$ne: null}}}
+      ]).toArray();
+      
+    
+      console.log(results);
+    
+      await client.close();
+    }
+    
+    main();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false')
+    db = client['test']
+    users = db['users']
+    
+    results = list(users.aggregate([
+        { "$project": { "names": { "$regexFind": { "input": "$name", "regex": "john", "options": "i" }}}},
+        { "$match": {"names": {"$ne": None}}}
+    ]))
+    
+    print(results)
+    
+    client.close()
+
+![Warning](https://d1ge0kk1l5kms0.cloudfront.net/images/G/01/webservices/console/warning.png) **Javascript is disabled or is unavailable in your browser.**
+
+To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.
+
+[Document Conventions](/general/latest/gr/docconventions.html)
+
+$reduce
+
+$regexFindAll
+
+Did this page help you? - Yes
+
+Thanks for letting us know we're doing a good job!
+
+If you've got a moment, please tell us what we did right so we can do more of it.
+
+Did this page help you? - No
+
+Thanks for letting us know this page needs work. We're sorry we let you down.
+
+If you've got a moment, please tell us how we can make the documentation better.