Skip to content

Commit cd97009

Browse files
authored
Update run-python-tests.yml
Adding index creation
1 parent f47db50 commit cd97009

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/run-python-tests.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,59 @@ jobs:
4141
- name: Add sample data to database
4242
run: mongorestore --archive=sampledata.archive --port=27017
4343

44+
- name: Setup Database (Data & Indexes)
45+
run: |
46+
# ---------------------------------------------------------
47+
# 1. Prepare the Search Index Definition
48+
# ---------------------------------------------------------
49+
echo '{
50+
"mappings": {
51+
"dynamic": false,
52+
"fields": {
53+
"plot": {"type": "string", "analyzer": "lucene.standard"},
54+
"fullplot": {"type": "string", "analyzer": "lucene.standard"},
55+
"directors": {"type": "string", "analyzer": "lucene.standard"},
56+
"writers": {"type": "string", "analyzer": "lucene.standard"},
57+
"cast": {"type": "string", "analyzer": "lucene.standard"}
58+
}
59+
}
60+
}' > search_index.json
61+
62+
# 3. Create the Search Index
63+
atlas deployments search indexes create movieSearchIndex \
64+
--deploymentName myLocalRs1 \
65+
--db sample_mflix \
66+
--collection movies \
67+
--file search_index.json
68+
69+
# ---------------------------------------------------------
70+
# 2. Prepare the Vector Index Definition
71+
# ---------------------------------------------------------
72+
echo '{
73+
"fields": [
74+
{
75+
"type": "vector",
76+
"path": "plot_embedding_voyage_3_large",
77+
"numDimensions": 2048,
78+
"similarity": "cosine"
79+
}
80+
]
81+
}' > vector_index.json
82+
83+
# 4. Create the Vector Index
84+
atlas deployments search indexes create vector_index \
85+
--deploymentName myLocalRs1 \
86+
--db sample_mflix \
87+
--collection embedded_movies \
88+
--type vectorSearch \
89+
--file vector_index.json
90+
91+
# ---------------------------------------------------------
92+
# 6. Wait for indexes to build
93+
# ---------------------------------------------------------
94+
echo "Waiting for indexes to build..."
95+
sleep 20
96+
4497
- name: Set up Python
4598
uses: actions/setup-python@v5
4699
with:

0 commit comments

Comments
 (0)