File size: 3,048 Bytes
3c34409
 
 
 
 
 
 
 
 
 
e62ab21
3c34409
 
 
 
 
 
 
 
e62ab21
3c34409
 
 
 
 
 
 
 
 
 
 
e62ab21
3c34409
 
 
 
 
 
 
 
d93456f
3c34409
 
 
 
 
 
 
 
 
 
27f24d8
47d5b57
 
 
e62ab21
47d5b57
 
 
 
 
 
 
 
27f24d8
3c34409
 
 
 
 
 
 
 
 
 
 
 
 
 
e62ab21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Author     : Georgios Ioannou
#
# Copyright © 2024 by Georgios Ioannou

# Setting Up MongoDB with Atlas Vector Search

## Initial Setup
1. Create and log in to your MongoDB account at [mongodb.com](https://mongodb.com)

2. Create Organization and Project
   - **Note that if you first create an account you have a default organization and project so you may need to skip Step 2.**
   - Create a new MongoDB organization
   - Name your organization as desired
   - Create a new MongoDB project
   - Name your project as desired

3. Create Cluster
   - Select M0 (FREE) tier
   - Make sure to uncheck "Preload sample dataset"
   - **Keep everything else default.**
   - Wait 1-3 minutes for cluster creation

## Security Setup
4. Create Database User
   - Create username and password
   - Then, click on continue.
   - Then, just close no need to choose a connection method.
   - **Important**: Save these credentials securely

5. Configure Network Access
   - Navigate on the left menu to Security -> Network Access
   - **Add IP Address: `0.0.0.0/0` (Allows access from anywhere)**

## Database Creation
6. Set Up Database and Collection
   - Click "Clusters" on the left under "Database".
   - Click "Browse Collections"
   - Click "Add My Own Data"
   - Create database (e.g., "txts")
   - Create collection (e.g., "txts_collection")
   - No need to select any additional preferences.
   - Click "Create"

## Vector Search Configuration
7. Create Vector Search Index
   - Click "Search Indexes" (This will bring you to "Atlas Search" tab)
   - Click "Create Search Index"
   - Select "JSON Editor" under "Atlas Vector Search"
   - Click "Next"
   - Configure index settings:
     ```json
         {
            "fields": [
                        {
                           "numDimensions": 768, // Adjust based on your model. (e.g., 768 for all-mpnet-base-v2 )
                           "path": "embedding", // Adjust it to your index/embedding column.
                           "similarity": "euclidean", // Adjust it to your desired similarity function.
                           "type": "vector"
                        },
                        {
                           "path": "source", // Adjust it to the column you would like to filter with.
                           "type": "filter"
                        }
                      ]
      }
     ```
   - Assign your index to the collection name created in step 6 using the drop down menu on the left.
   - Click "Next"
   - Click "Create Search Index"
   - Wait for status to change from "Pending" to "Active"

**Note**: While vector search index creation can be done programmatically, the GUI method described above is recommended for simplicity.

## Connection String
8. Get Your MongoDB URI
   - Click "Clusters" under DATABASE on the left menu
   - Click "Connect" next to name of your cluster
   - Select "Drivers"
   - Copy the connection/MongoURI string at the very end of the modal that just opened
   - Replace **`<password>`** with your database user password