AWS documentdb documentation change
Summary
Added new documentation page for the $maxDistance operator in Amazon DocumentDB, including detailed explanation, MongoDB shell example, and code examples in Node.js and Python
Security assessment
This change adds documentation for a geospatial query operator ($maxDistance) used with $nearSphere. The content focuses on functionality and usage examples without addressing any security vulnerabilities or weaknesses. The code examples include standard TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security practices for DocumentDB connections, but these are not new security features being documented - they're part of the standard connection string template. No evidence of addressing a specific security issue.
Diff
diff --git a/documentdb/latest/developerguide/maxDistance.md b/documentdb/latest/developerguide/maxDistance.md index 8b1378917..21a44c197 100644 --- a//documentdb/latest/developerguide/maxDistance.md +++ b//documentdb/latest/developerguide/maxDistance.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#maxDistance "Open PDF") @@ -1,0 +3,133 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $maxDistance + +The `$maxDistance` operator in Amazon DocumentDB is used to specify the maximum distance (in meters) from a GeoJSON point that documents must be within to be included in the query results. This operator is used in conjunction with the `$nearSphere` operator to perform geospatial queries. + +**Parameters** + + * `$maxDistance`: The maximum distance (in meters) from the reference point that documents must be within to be included in the query results. + + + + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$maxDistance` operator in Amazon DocumentDB to find all state capitals within 100 kilometers of Boston. + +**Create sample documents** + + + db.capitals.insert([ + { state: "Massachusetts", city: "Boston", location: { type: "Point", coordinates: [-71.0589, 42.3601] } }, + { state: "Rhode Island", city: "Providence", location: { type: "Point", coordinates: [-71.4128, 41.8239] } }, + { state: "New Hampshire", city: "Concord", location: { type: "Point", coordinates: [-71.5383, 43.2067] } }, + { state: "Vermont", city: "Montpelier", location: { type: "Point", coordinates: [-72.5751, 44.2604] } } + ]); + +**Query example** + + + db.capitals.find( + { + location: { + $nearSphere: { + $geometry: { type: "Point", coordinates: [-71.0589, 42.3601] }, + $maxDistance: 100000 + } + } + }, + { state: 1, city: 1, _id: 0 } + ); + +**Output** + + + [ + { "state": "Rhode Island", "city": "Providence" }, + { "state": "New Hampshire", "city": "Concord" } + ] + +## Code examples + +To view a code example for using the `$maxDistance` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function findCapitalsNearBoston() { + 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 capitals = db.collection('capitals'); + + const result = await capitals.find({ + location: { + $nearSphere: { + $geometry: { type: "Point", coordinates: [-71.0589, 42.3601] }, + $maxDistance: 100000 + } + } + }, { + projection: { state: 1, city: 1, _id: 0 } + }).toArray(); + + console.log(result); + await client.close(); + } + + findCapitalsNearBoston(); + +Python + + + + from pymongo import MongoClient + + def find_capitals_near_boston(): + client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') + db = client.test + capitals = db.capitals + + result = list(capitals.find( + { + "location": { + "$nearSphere": { + "$geometry": { "type": "Point", "coordinates": [-71.0589, 42.3601] }, + "$maxDistance": 100000 + } + } + }, + {"state": 1, "city": 1, "_id": 0} + )) + + print(result) + client.close() + + find_capitals_near_boston() + + **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) + +$geoWithin + +$minDistance + +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.