Create mongodb_atlas_vector_search_setup.md
Browse files
mongodb_atlas_vector_search_setup.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Author : Georgios Ioannou
|
| 2 |
+
#
|
| 3 |
+
# Copyright © 2024 by Georgios Ioannou
|
| 4 |
+
|
| 5 |
+
# Setting Up MongoDB with Atlas Vector Search
|
| 6 |
+
|
| 7 |
+
## Initial Setup
|
| 8 |
+
1. Create and log in to your MongoDB account at [mongodb.com](https://mongodb.com)
|
| 9 |
+
|
| 10 |
+
2. Create Organization and Project
|
| 11 |
+
- Create a new MongoDB organization
|
| 12 |
+
- Name your organization as desired
|
| 13 |
+
- Create a new MongoDB project
|
| 14 |
+
- Name your project as desired
|
| 15 |
+
|
| 16 |
+
3. Create Cluster
|
| 17 |
+
- Select M0 (FREE) tier
|
| 18 |
+
- Wait 1-3 minutes for cluster creation
|
| 19 |
+
|
| 20 |
+
## Security Setup
|
| 21 |
+
4. Create Database User
|
| 22 |
+
- Create username and password
|
| 23 |
+
- **Important**: Save these credentials securely
|
| 24 |
+
|
| 25 |
+
5. Configure Network Access
|
| 26 |
+
- Navigate on the left menu to Security -> Network Access
|
| 27 |
+
- Add IP Address: `0.0.0.0/0` (Allows access from anywhere)
|
| 28 |
+
|
| 29 |
+
## Database Creation
|
| 30 |
+
6. Set Up Database and Collection
|
| 31 |
+
- Click "Browse Collections"
|
| 32 |
+
- Click "Add My Own Data"
|
| 33 |
+
- Create database (e.g., "txts")
|
| 34 |
+
- Create collection (e.g., "txts_collection")
|
| 35 |
+
- Click "Create"
|
| 36 |
+
|
| 37 |
+
## Vector Search Configuration
|
| 38 |
+
7. Create Vector Search Index
|
| 39 |
+
- Click "Search Indexes" (This will bring you to "Atlas Search" tab)
|
| 40 |
+
- Click "Create Search Index"
|
| 41 |
+
- Select "JSON Editor" under "Atlas Vector Search"
|
| 42 |
+
- Click "Next"
|
| 43 |
+
- Configure index settings:
|
| 44 |
+
```json
|
| 45 |
+
{
|
| 46 |
+
"name": "vector_index", // Adjust it to your desired name.
|
| 47 |
+
"type": "vector",
|
| 48 |
+
"path": "embedding", // Adjust it to your index/embedding column.
|
| 49 |
+
"numDimensions": 384, // Adjust based on your model. (e.g., 384 for all-MiniLM-l6-v2)
|
| 50 |
+
"similarity": "euclidean" // Adjust it to your desired similarity function.
|
| 51 |
+
}
|
| 52 |
+
```
|
| 53 |
+
- Optional: Add filter fields if needed:
|
| 54 |
+
```json
|
| 55 |
+
{
|
| 56 |
+
"type": "filter",
|
| 57 |
+
"path": "source" // Adjust it to the column you would like to filter with.
|
| 58 |
+
}
|
| 59 |
+
```
|
| 60 |
+
- Assign your index to the collection name created in step 6 using the drop down menu on the left.
|
| 61 |
+
- Click "Next"
|
| 62 |
+
- Click "Create Search Index"
|
| 63 |
+
- Wait for status to change from "Pending" to "Active"
|
| 64 |
+
|
| 65 |
+
**Note**: While vector search index creation can be done programmatically, the GUI method described above is recommended for simplicity.
|
| 66 |
+
|
| 67 |
+
## Connection String
|
| 68 |
+
8. Get Your MongoDB URI
|
| 69 |
+
- Click "Clusters" under DATABASE on the left menu
|
| 70 |
+
- Click "Connect" next to name of your cluster
|
| 71 |
+
- Select "Drivers"
|
| 72 |
+
- Copy the connection/MongoURI string at the very end of the modal that just opened
|
| 73 |
+
- Replace `<password>` with your database user password
|