AWS documentdb documentation change
Summary
Added new documentation page for the $minDistance operator in Amazon DocumentDB, including detailed explanation, MongoDB shell example, and code examples in Node.js and Python
Security assessment
This change adds routine documentation for a geospatial query operator ($minDistance) used with $nearSphere and $geoNear. The documentation includes standard usage examples and connection strings with TLS parameters, but there is no evidence of addressing a specific security vulnerability, weakness, or incident. The TLS parameters shown in code examples (tls=true, tlsCAFile=global-bundle.pem) are standard security best practices for DocumentDB connections, but this is not new security documentation - it's part of routine example code.
Diff
diff --git a/documentdb/latest/developerguide/minDistance.md b/documentdb/latest/developerguide/minDistance.md index 8b1378917..4a93fed7d 100644 --- a//documentdb/latest/developerguide/minDistance.md +++ b//documentdb/latest/developerguide/minDistance.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#minDistance "Open PDF") @@ -1,0 +3,167 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $minDistance + +`$minDistance` is a find operator used in conjunction with `$nearSphere` or `$geoNear` to filter documents that are at least at the specified minimum distance from the center point. This operator is supported in Amazon DocumentDB and functions similarly to its counterpart in MongoDB. + +**Parameters** + + * `$minDistance`: The minimum distance (in meters) from the center point to include documents in the results. + + + + +## Example (MongoDB Shell) + +In this example, we'll find all restaurants within a 2-kilometer radius of a specific location in Seattle, Washington. + +**Create sample documents** + + + db.usarestaurants.insertMany([ + { + "state": "Washington", + "city": "Seattle", + "name": "Noodle House", + "rating": 4.8, + "location": { + "type": "Point", + "coordinates": [-122.3517, 47.6159] + } + }, + { + "state": "Washington", + "city": "Seattle", + "name": "Pike Place Grill", + "rating": 4.5, + "location": { + "type": "Point", + "coordinates": [-122.3412, 47.6102] + } + }, + { + "state": "Washington", + "city": "Bellevue", + "name": "The Burger Joint", + "rating": 4.2, + "location": { + "type": "Point", + "coordinates": [-122.2007, 47.6105] + } + } + ]); + +**Query example** + + + db.usarestaurants.find({ + "location": { + "$nearSphere": { + "$geometry": { + "type": "Point", + "coordinates": [-122.3516, 47.6156] + }, + "$minDistance": 1, + "$maxDistance": 2000 + } + } + }, { + "name": 1 + }); + +**Output** + + + { "_id" : ObjectId("611f3da985009a81ad38e74b"), "name" : "Noodle House" } + { "_id" : ObjectId("611f3da985009a81ad38e74c"), "name" : "Pike Place Grill" } + +## Code examples + +To view a code example for using the `$minDistance` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function findRestaurantsNearby() { + 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('usarestaurants'); + + const result = await collection.find({ + "location": { + "$nearSphere": { + "$geometry": { + "type": "Point", + "coordinates": [-122.3516, 47.6156] + }, + "$minDistance": 1, + "$maxDistance": 2000 + } + } + }, { + "projection": { "name": 1 } + }).toArray(); + + console.log(result); + client.close(); + } + + findRestaurantsNearby(); + +Python + + + + from pymongo import MongoClient + + def find_restaurants_nearby(): + 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.usarestaurants + + result = list(collection.find({ + "location": { + "$nearSphere": { + "$geometry": { + "type": "Point", + "coordinates": [-122.3516, 47.6156] + }, + "$minDistance": 1, + "$maxDistance": 2000 + } + } + }, { + "projection": {"name": 1} + })) + + print(result) + client.close() + + find_restaurants_nearby() + + **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) + +$maxDistance + +$near + +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.