4040)
4141
4242# Create auto-embed index (private preview-style syntax)
43- movies .create_search_index (model = SearchIndexModel (
44- name = "auto_embed_plot_index" ,
45- type = "vectorSearch" ,
46- definition = {
47- "fields" : [
48- {
49- "type" : "text" ,
50- "path" : "plot" ,
51- "model" : "voyage-3-large" ,
52- },
53- ],
54- })
43+ movies .create_search_index (
44+ model = SearchIndexModel (
45+ name = "auto_embed_plot_index" ,
46+ type = "vectorSearch" ,
47+ definition = {
48+ "fields" : [
49+ {
50+ "type" : "text" ,
51+ "path" : "plot" ,
52+ "model" : "voyage-3-large" ,
53+ },
54+ ],
55+ },
56+ )
5557)
5658
5759# Create normal vector index
58- movies .create_search_index (model = SearchIndexModel (
59- name = "plot_vector_index" ,
60- type = "vectorSearch" ,
61- definition = {
62- "fields" : [
63- {
64- "type" : "vector" ,
65- "path" : "plot_embeddings" ,
66- "numDimensions" : 1024 ,
67- "similarity" : "cosine" ,
68- "quantization" : "none" ,
69- },
70- ],
71- })
60+ movies .create_search_index (
61+ model = SearchIndexModel (
62+ name = "plot_vector_index" ,
63+ type = "vectorSearch" ,
64+ definition = {
65+ "fields" : [
66+ {
67+ "type" : "vector" ,
68+ "path" : "plot_embeddings" ,
69+ "numDimensions" : 1024 ,
70+ "similarity" : "cosine" ,
71+ "quantization" : "none" ,
72+ },
73+ ],
74+ },
75+ )
7276)
7377
7478
75-
7679# Run vector search aggregation using auto-embed index
7780cursor = movies .aggregate (
7881 [
9093
9194for doc in cursor :
9295 print (doc )
93- assert doc [' title' ] == "Breathe"
96+ assert doc [" title" ] == "Breathe"
0 commit comments