AWS Security ChangesHomeSearch

AWS documentdb documentation change

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

File: documentdb/latest/developerguide/meta-aggregation.md

Summary

Added new documentation page for the $meta aggregation operator in Amazon DocumentDB, including overview, parameters, MongoDB shell example, and code examples in Node.js and Python

Security assessment

The change adds documentation for a database aggregation operator ($meta) used for text search scoring. While the code examples include TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which are security best practices for encrypted connections, there is no evidence this addresses a specific security vulnerability or incident. The documentation primarily focuses on feature functionality rather than security remediation.

Diff

diff --git a/documentdb/latest/developerguide/meta-aggregation.md b/documentdb/latest/developerguide/meta-aggregation.md
index 8b1378917..52b0aebeb 100644
--- a//documentdb/latest/developerguide/meta-aggregation.md
+++ b//documentdb/latest/developerguide/meta-aggregation.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#meta-aggregation "Open PDF")
@@ -1,0 +3,127 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $meta
+
+The `$meta` aggregation operator accesses metadata associated with documents in an aggregation pipeline. It is commonly used to retrieve text search scores and sort results by relevance.
+
+**Parameters**
+
+  * `textScore`: Retrieves the text search score indicating document relevance to the search query.
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates using the `$meta` operator in an aggregation pipeline to retrieve and sort by text search scores.
+
+**Create sample documents**
+    
+    
+    db.articles.createIndex({ content: "text" });
+    
+    db.articles.insertMany([
+      { _id: 1, title: "Python Programming", content: "Python is a versatile programming language used for web development." },
+      { _id: 2, title: "Python Guide", content: "Learn Python programming with Python tutorials and Python examples." },
+      { _id: 3, title: "Java Basics", content: "Java is another popular programming language." }
+    ]);
+
+**Query example**
+    
+    
+    db.articles.aggregate([
+      { $match: { $text: { $search: "Python" } } },
+      { $addFields: { score: { $meta: "textScore" } } },
+      { $sort: { score: -1 } }
+    ]);
+
+**Output**
+    
+    
+    [
+      {
+        _id: 2,
+        title: 'Python Guide',
+        content: 'Learn Python programming with Python tutorials and Python examples.',
+        score: 1.5
+      },
+      {
+        _id: 1,
+        title: 'Python Programming',
+        content: 'Python is a versatile programming language used for web development.',
+        score: 0.75
+      }
+    ]
+
+## Code examples
+
+To view a code example for using the `$meta` aggregation operator, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function example() {
+      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 collection = db.collection('articles');
+    
+      const result = await collection.aggregate([
+        { $match: { $text: { $search: "Python" } } },
+        { $addFields: { score: { $meta: "textScore" } } },
+        { $sort: { score: -1 } }
+      ]).toArray();
+    
+      console.log(result);
+      await client.close();
+    }
+    
+    example();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def example():
+        client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false')
+        db = client['test']
+        collection = db['articles']
+    
+        result = list(collection.aggregate([
+            { '$match': { '$text': { '$search': 'Python' } } },
+            { '$addFields': { 'score': { '$meta': 'textScore' } } },
+            { '$sort': { 'score': -1 } }
+        ]))
+    
+        print(result)
+        client.close()
+    
+    example()
+
+![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)
+
+$max
+
+$merge
+
+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.