For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

MongoDB Vector Search Quick Start Tutorial

Important

Automated Embeddings is available as a Preview feature. The feature and the corresponding documentation might change at any time during the Preview period. Do not use this feature in your production environment. We do not use any customer data from this feature to train our models at this time. To learn more, see Preview Features.

This quick start describes how to load sample documents that contain vector embeddings into your cluster, create a MongoDB Vector Search index on those embeddings, and then perform semantic search to return documents that are similar to your query.

Time required: 15 minutes

In this quick start, you complete the following steps:

  1. Create an index definition for the sample_mflix.embedded_movies collection that indexes the plot_embedding_voyage_3_large field as the vector type. The plot_embedding_voyage_3_large field contains embeddings created using Voyage AI's voyage-3-large embedding model. The index definition specifies 2048 vector dimensions and measures similarity using dotProduct.

  2. Run a MongoDB Vector Search query that searches the sample sample_mflix.embedded_movies collection. The query uses the $vectorSearch stage to search the plot_embedding_voyage_3_large field, which contains embeddings created using Voyage AI's voyage-3-large embedding model. The query searches the plot_embedding_voyage_3_large field using vector embeddings for the string time travel. It considers up to 150 nearest neighbors, and returns 10 documents in the results.

To learn more, see Learning Summary.

This quick start describes how to create a local Atlas deployment with sample data loaded into the deployment, create a MongoDB Vector Search index for the sample data, and then perform semantic search to return documents that are similar to your query.

Time required: 15 minutes

In this quick start, you complete the following steps:

  1. Deploy Atlas locally via Atlas CLI with sample data loaded.

    To create a local Atlas deployment using Docker commands, see Create a Local Atlas Deployment with Docker.

  2. Create an index definition for the sample_mflix.embedded_movies collection that indexes the plot_embedding_voyage_3_large field as the vector type. The plot_embedding_voyage_3_large field contains embeddings created using Voyage AI's voyage-3-large embedding model. The index definition specifies 2048 vector dimensions and measures similarity using dotProduct.

  3. Run a MongoDB Vector Search query that searches the sample sample_mflix.embedded_movies collection. The query uses the $vectorSearch stage to search the plot_embedding_voyage_3_large field, which contains embeddings created using Voyage AI's voyage-3-large embedding model. The query searches the plot_embedding_voyage_3_large field using vector embeddings for the string time travel. It considers up to 150 nearest neighbors, and returns 10 documents in the results.

To learn more, see Learning Summary.

Before you begin, you must download the following:

  • Docker

  • Atlas CLI v5.3.1 or later

This quick start demonstrates how to deploy MongoDB Search and MongoDB Vector Search in Docker, load sample data into the MongoDB cluster, create a MongoDB Vector Search index for the sample data, and run vector search queries against the sample data.

Time required: 20 minutes

The quick start walks you through the following steps:

  1. Deploy MongoDB and mongot in Docker.

    For more details on deploying by using a tarball or as an image in Docker, see Install MongoDB Community and MongoDB Search.

  2. Load sample data, create a vector search index, and run vector search queries on your local deployment.

Note

The resulting set up of this quick start is not secure. For more information on securing your deployment, see Security for Self-Managed Deployments.

This tutorial creates the following architecture:

  • A MongoDB Community Edition Server (mongod) with a single node replica set on port 27017

  • A MongoDB Search (mongot) search engine component on port 27028

  • Persistant data volumes on both ports

  • Pre-loaded sample data

Note

For a production deployment, MongoDB recommends that you use a replica set with at least three members.

Before you begin, you must download the following:

  • Docker v4.40 or higher

  • Docker Compose

  • curl command

  • mongosh locally or have access to it through Docker

This quick start describes how to load sample documents that contain text data into your cluster, create a MongoDB Vector Search index on a text field in the collection to automatically generate embeddings for the text data at index time and query time, and then perform semantic search to return documents that are similar to your query.

Time required: 15 minutes

In this quick start, you complete the following steps:

  1. Create an index definition for the sample_mflix.movies collection that indexes the fullplot field as the autoEmbed type. The index definition specifies voyage-4 as the model to use for generating embeddings for the fullplot field.

  2. Run a MongoDB Vector Search query that searches the sample sample_mflix.movies collection. The query uses the $vectorSearch stage to search the fullplot field. The query performs a semantic search for the phrase journey through the country side using the embedding generated at query time using the voyage-4 embedding model. It considers up to 100 nearest neighbors, and returns 10 documents in the results.

To learn more, see Learning Summary.

This quick start describes how to create a local Atlas deployment with sample data loaded into the deployment, create a MongoDB Vector Search index for the sample data, and then perform semantic search to return documents that are similar to your query.

Time required: 15 minutes

In this quick start, you complete the following steps:

  1. Deploy Atlas locally via Atlas CLI with sample data loaded.

    To create a local Atlas deployment using Docker commands, see Create a Local Atlas Deployment with Docker.

  2. Create an index definition for the sample_mflix.movies collection that indexes the fullplot field as the autoEmbed type. The index definition specifies voyage-4 as the embedding model to use for generating embeddings for the fullplot field.

  3. Run a MongoDB Vector Search query that searches the sample sample_mflix.movies collection. The query uses the $vectorSearch stage to search the fullplot field for the movies semantically similar to the query string journey through the country side. It considers up to 100 nearest neighbors and returns 10 documents in the results.

To learn more, see Learning Summary.

Before you begin, you must have the following:

  • Docker

  • Atlas CLI v5.3.1 or later

  • Voyage AI API keys created from the Atlas UI

    To learn more about creating a Voyage AI API key from the Atlas UI, see Manage Voyage AI Model API Keys.

    Note

    Local Atlas deployment doesn't support Voyage AI API keys created directly from Voyage AI.

This quick start demonstrates how to deploy MongoDB Search and MongoDB Vector Search in Docker, load sample data into the MongoDB cluster, create a vector search index for the sample data, and run vector search queries against the sample data.

Time required: 20 minutes

The quick start walks you through the following steps:

  1. Deploy MongoDB and mongot in Docker.

    For more details on deploying by using a tarball or as an image in Docker, see Install MongoDB Community and MongoDB Search.

  2. Load sample data, create a vector search index, and run vector search queries on your local deployment.

Note

The resulting set up of this quick start is not secure. For more information on securing your deployment, see Security for Self-Managed Deployments.

This tutorial creates the following architecture:

  • A MongoDB Community Edition Server (mongod) with a single node replica set on port 27017

  • A MongoDB Search (mongot) search engine component on port 27028

  • Persistant data volumes on both ports

  • Pre-loaded sample data

Note

For a production deployment, MongoDB recommends that you use a replica set with at least three members.

Before you begin, you must complete the following prerequisites:

  • Download Docker v4.40 or higher

  • Download Docker Compose

  • Download the curl command

  • Download mongosh locally or have access to it through Docker

  • Create Voyage AI API keys from the Atlas UI or directly from Voyage AI

    We recommend two separate keys to enable MongoDB Vector Search to automatically generate embeddings at index- and query-time.

Note

Your provider endpoint for generating embeddings depends on whether you create the API key from the Atlas UI or directly from Voyage AI.

1
  1. If you don't yet have an Atlas cluster, create a free M0 cluster. To learn more about creating an Atlas cluster, see Create a Cluster.

    IMPORTANT: If you are working with an existing cluster, you must have Project Data Access Admin or higher access to your Atlas project.

    If you create a new cluster, you have the necessary permissions by default.

    You can create only one M0 Free cluster per project.

2
  1. If you haven't yet loaded the sample dataset for this quick start onto your cluster, load the sample_mflix sample database onto your cluster.

    If you already loaded the sample_mflix dataset, check that the sample_mflix database contains the embedded_movies collection. If it doesn't, drop the sample_mflix database and reload the sample_mflix dataset.

    Loading the sample dataset can take several minutes to complete.

  2. In the left sidebar, click Search & Vector Search. Choose your cluster from the Select data source menu and click Go to Atlas Search.

1
MONGODB_ATLAS_LOCAL_PREVIEW=true atlas local setup --loadSampleData true --force
"Installing first class plugin atlas-local-plugin"
"Plugin mongodb/atlas-local-cli successfully installed"
[1/4] [✅] Pulling the latest version of the MongoDB image...
[2/4] [✅] Creating the deployment...
[3/4] [✅] Starting the deployment...
[4/4] [✅] Waiting for the deployment to be healthy...
{"outcome":"setup","deployment_name":"local7816","mongodb_version":"8.2.5","port":53211,"load_sample_data":true,"connect_result":{"connect_outcome":"skipped"}}
2

To connect, run the following command after replacing <deployment_name> with the name of your local Atlas deployment.

atlas local connect --connectWith mongosh <deployment_name>
1

To download the mongot Docker image and the latest MongoDB Community Edition image, run the following command:

docker pull mongodb/mongodb-community-server:latest && docker pull mongodb/mongodb-community-search:latest

Note

You must have a minimum of MongoDB 8.2.0 to use MongoDB Search with a self-managed deployment. For more information, see MongoDB Search Compatibility.

2

To download the sample data, run the following command:

curl https://atlas-education.s3.amazonaws.com/sampledata.archive -o sampledata.archive
3

Create a password file for mongot to connect to mongod.

Important

Do not include trailing new lines in your password file. mongot rejects password files that contain trailing newlines.

Select your operating system and run the command to create your password file:

echo -n "mongotPassword" > pwfile
chmod 400 pwfile

Note

The -n flag prevents a trailing newline.

Note

  • If you change the mongot password, you must also update the password value in the init-mongo-sh script.

  • Most text editors automatically add newlines to files when you edit files manually.

4

Create the following configuration files in your project folder and paste the provided code for each file:

5

To create the Docker network, run the following command:

docker network create search-community
6

Use the following steps to launch both services:

  1. Launch mongod and mongot:

    docker compose up -d
  2. Wait for both services to fully initialize.

    To monitor the logs of both services, run the following command:

    docker compose logs -f

    The initialization is complete when the logs return MongoDB initialization completed.

1

To create a local Atlas deployment, run the following command after replacing <voyage_api_key> with the Voyage AI API key created from the Atlas UI.

MONGODB_ATLAS_LOCAL_PREVIEW=true MONGODB_ATLAS_LOCAL_VOYAGE_API_KEY=<voyage_api_key> atlas local setup --loadSampleData true --force
"Installing first class plugin atlas-local-plugin"
"Plugin mongodb/atlas-local-cli successfully installed"
[1/4] [✅] Pulling the latest version of the MongoDB image...
[2/4] [✅] Creating the deployment...
[3/4] [✅] Starting the deployment...
[4/4] [✅] Waiting for the deployment to be healthy...
{"outcome":"setup","deployment_name":"local7816","mongodb_version":"8.2.5","port":53211,"load_sample_data":true,"connect_result":{"connect_outcome":"skipped"}}
2

To connect, run the following command after replacing <deployment_name> with the name of your local Atlas deployment.

atlas local connect --connectWith mongosh <deployment_name>
1

To pull the mongot Docker image, run the following command:

docker pull mongodb/mongodb-community-search:latest

To verify the image is on your Docker Desktop, run the following command:

docker image ls mongodb/mongodb-community-search
2

To create a docker network for inter-container communication between the database and search containers, run the following command:

docker network create search-community
3

To download the MongoDB Docker image, run the following command:

docker pull mongodb/mongodb-community-server:latest

Note

You must have a minimum of MongoDB 8.3+ to use MongoDB Search with an on-prem deployment. For more information, see MongoDB Search Compatibility.

For additional details on installing MongoDB with Docker, see Install MongoDB Community with Docker.

4

Create a password file for mongot to connect to mongod. Select your operating system and run the command:

Replace <mongot_password> with your password and run the following command to create a file called passwordFile in your current directory:

echo -n "<mongot_password>" > passwordFile
chmod 400 passwordFile

Note

The -n flag prevents a trailing newline.

5

To create your configuration file, save the following code to mongod.conf or your preferred location.

# MongoDB Configuration File
# Network configuration
net:
port: 27017
bindIpAll: true # Equivalent to --bind_ip_all
# Replica set configuration
replication:
replSetName: rs0
# Search configuration parameters
setParameter:
# Server parameters to advise mongod of mongot availability for search index management and querying
searchIndexManagementHostAndPort: mongot-community.search-community:27028
mongotHost: mongot-community.search-community:27028
skipAuthenticationToSearchIndexManagementServer: false
useGrpcForSearch: true
searchTLSMode: disabled
6

To start the mongod:

  • Replace </path/to/data/db> with the path to the local directory for the mounted volume.

  • Replace </path/to/mongod.conf> with the path to the configuration file you created above.

  • On Windows, replace the backslash (\) at the end of each line with the line continuation character for your shell. Command Prompt uses a caret (^), and PowerShell uses a backtick.

docker run --rm \
--name mongod \
-v </path/to/mongod.conf>:/etc/mongod.conf:ro \
-v </path/to/data/db>:/data/db \
-p 27017:27017 \
--network search-community \
mongodb/mongodb-community-server:latest \
--config /etc/mongod.conf \
--replSetMember=mongod.search-community:27017
7

Run the following command to connect to the mongod instance you started on port 27017:

docker exec -it mongod mongosh --port 27017
8

mongot must be able to connect to your MongoDB deployment through a user with the searchCoordinator role.

Run the following command to connect to the admin database:

use admin

To create a user with the searchCoordinator role:

  • Replace <mongot_username> with a username for your mongot user.

  • Replace <mongot_password> with the password that you specified in your passwordFile in step 4.

  • Run the following command:

db.createUser(
{
user: "<mongot_username>",
pwd: "<mongot_password>",
roles: [ "searchCoordinator" ]
}
)

For more information on creating users, see Create a User on Self-Managed Deployments.

9

You can configure mongot with a YAML configuration file. You must specify the username that you specified in the previous step as the syncSource.replicaSet.scramAuth.username. You must also specify the passwordFile that you created in the previous step as the syncSource.replicaSet.scramAuth.passwordFile.

For more information on mongot configuration options, see mongot Options.

For example, you can adapt the settings to your local configuration as shown below:

# mongot.conf
syncSource:
replicaSet:
hostAndPort: "mongod.search-community:27017"
scramAuth:
username: "mongotUser"
passwordFile: "/passwordFile"
authSource: "admin"
tls:
enabled: false
replicationReader:
readPreference: "secondaryPreferred"
storage:
dataPath: "/data/mongot"
server:
grpc:
address: "mongot-community.search-community:27028"
tls:
mode: "disabled"
metrics:
enabled: true
address: "mongot-community.search-community:9946"
healthCheck:
address: "mongot-community.search-community:8080"
logging:
verbosity: INFO

Save your file to mongot.config or your preferred file location.

Both containers run on the same search-community Docker network.

10

To start the Search in Community binary (mongot), select your operating system and run the command:

  • Replace </path/to/data/mongot> with the path to the local directory for the mounted volume to store mongot data.

  • Replace </path/to/mongot.conf> with the path to the mongot configuration file that you created in the previous step.

  • Replace </path/to/passwordFile> with the path to the password file that you created.

docker run --rm \
--name mongot-community \
-v </path/to/data/mongot>:/data/mongot \
-v </path/to/mongot.conf>:/mongot-community/config.default.yml \
-v </path/to/passwordFile>:/passwordFile:ro \
--network search-community \
-p 8080:8080 \
-p 9946:9946 \
mongodb/mongodb-community-search:latest

This command:

  • Mounts the volume.

  • Mounts a configuration file from a local volume.

  • Specifies the port range.

  • Exposes the metrics port.

  • Starts the container on the search-community Docker network with a container named mongot-community.

11

To verify, send a request by using a HTTP client or curl to the /health endpoint. For example, send a curl request similar to the following sample request:

curl localhost:8080/health

The endpoint returns one of the following in the response:

  • SERVING, if the mongot process is running

    mongot might not serve queries as it doesn't check the status of the indexes, which must be in Ready state to serve queries.

  • NOT_SERVING, if the mongot process isn't running

For more information, see Verify Your mongot Connection.

In this section, you create a MongoDB Vector Search index on sample data that you load into your cluster:

1
2

Search Type

Select the Vector Search index type.

How do you want to set up your vector data?

Select one of the following:

  • Automated Embedding if you want MongoDB to generate and manage vector embeddings for your text fields.

  • Bring your own embeddings if you have already generated vector embeddings for your data.

Choose Bring your own embeddings.

Index Name and Data Source

Specify the following information:

  • Index Name: autoembed_index

  • Database and Collection:

    • sample_mflix

    • embedded_movies

Configuration Method

For a guided experience, select Visual Editor.

To edit the raw index definition, select JSON Editor.

3

Atlas automatically detects fields that contain vector embeddings, as well as their corresponding dimensions. For the sample_mflix.movies collection, the plot_embedding field displays.

To configure the index, do the following:

  1. Select Dot Product from the Similarity Method dropdown.

  2. Click the Advanced dropdown menu and select Scalar to automatically quantize the embeddings in the field.

This index definition:

4
5

The index should take about one minute to build. When your vector index is finished building, the Status column reads Active.

1

In a terminal window, run atlas deployments connect and follow the prompts to connect to your local Atlas deployment via mongosh. For detailed instructions on connecting, see Manage a Local Atlas Deployment.

2

Example

use sample_mflix
switched to db sample_mflix
3
1db.embedded_movies.createSearchIndex(
2 "vector_index",
3 "vectorSearch",
4 {
5 "fields": [
6 {
7 "type": "vector",
8 "path": "plot_embedding_voyage_3_large",
9 "numDimensions": 2048,
10 "similarity": "dotProduct",
11 "quantization": "scalar"
12 }
13 ]
14 }
15);

This index definition:

1

For detailed installation instructions, refer to the MongoDB C Driver documentation.

2
mkdir query-quick-start
3
cd query-quick-start
touch CMakeLists.txt

Copy and paste the following lines into the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.30)
project(atlas-vector-search-quick-start)
# Specify the minimum version for creating a vector index.
find_package (mongoc-1.0 1.28.0 REQUIRED)
add_executable(atlas-vector-search-quick-start
vector_index.c
)
target_link_libraries (atlas-vector-search-quick-start PRIVATE mongo::mongoc_shared)
4

Create a file named vector_index.c. Copy and paste the following code into the file.

vector_index.c
1#include <bson/bson.h>
2#include <mongoc/mongoc.h>
3#include <stdio.h>
4
5int main(void) {
6 mongoc_client_t *client;
7 mongoc_collection_t *collection;
8 bson_error_t error;
9 char database_name[] = "sample_mflix";
10 char collection_name[] = "embedded_movies";
11 char index_name[] = "vector_index";
12
13 mongoc_init();
14
15 // Replace the placeholder with your connection string
16 client = mongoc_client_new("<connection-string>");
17
18 // Connect to your cluster
19 collection = mongoc_client_get_collection (client, database_name, collection_name);
20
21 bson_t cmd;
22 // Create search index command.
23 {
24 char *cmd_str = bson_strdup_printf (
25 BSON_STR ({
26 "createSearchIndexes" : "%s",
27 "indexes" : [{
28 "definition": {
29 "fields": [{
30 "type": "vector",
31 "path": "plot_embedding_voyage_3_large",
32 "numDimensions": 2048,
33 "similarity": "dotProduct",
34 "quantization": "scalar"
35 }]
36 },
37 "name": "%s",
38 "type": "vectorSearch"
39 }]
40 }),
41 collection_name, index_name);
42 if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
43 printf("Failed to initialize BSON: %s\n", error.message);
44 bson_free(cmd_str);
45 return 1;
46 }
47 bson_free (cmd_str);
48 }
49 if (!mongoc_collection_command_simple (collection, &cmd, NULL /* read_prefs */, NULL /* reply */, &error)) {
50 bson_destroy (&cmd);
51 printf ("Failed to run createSearchIndexes: %s", error.message);
52 return 1;
53 } else {
54 printf ("New search index named %s is building.\n", index_name);
55 bson_destroy (&cmd);
56 }
57
58 // Polling for index status
59 printf("Polling to check if the index is ready. This may take up to a minute.\n");
60 int queryable = 0;
61 while (!queryable) {
62 const char *pipeline_str = "{\"pipeline\": [{\"$listSearchIndexes\": {}}]}";
63 bson_t pipeline;
64 if (!bson_init_from_json(&pipeline, pipeline_str, -1, &error)) {
65 printf("Failed to initialize pipeline BSON: %s\n", error.message);
66 break; // Exit the loop on error
67 }
68 mongoc_cursor_t *cursor = mongoc_collection_aggregate(collection, MONGOC_QUERY_NONE, &pipeline, NULL, NULL);
69 const bson_t *got;
70 // Check if the cursor returns any documents
71 int found_index = 0;
72 while (mongoc_cursor_next(cursor, &got)) {
73 bson_iter_t iter;
74 if (bson_iter_init(&iter, got) && bson_iter_find(&iter, "name")) {
75 const char *name = bson_iter_utf8(&iter, NULL);
76 if (strcmp(name, index_name) == 0) {
77 found_index = 1; // Index found
78 bson_iter_find(&iter, "queryable");
79 queryable = bson_iter_bool(&iter);
80 break; // Exit the loop since we found the index
81 }
82 }
83 }
84 if (mongoc_cursor_error(cursor, &error)) {
85 printf("Failed to run $listSearchIndexes: %s\n", error.message);
86 break; // Exit the loop on error
87 }
88 if (!found_index) {
89 printf("Index %s not found yet. Retrying...\n", index_name);
90 }
91 bson_destroy(&pipeline);
92 mongoc_cursor_destroy(cursor);
93 sleep(5); // Sleep for 5 seconds before checking again
94 }
95 if (queryable) {
96 printf("%s is ready for querying.\n", index_name);
97 } else {
98 printf("Error occurred or index not found.\n");
99 }
100
101 // Cleanup
102 mongoc_collection_destroy(collection);
103 mongoc_client_destroy(client);
104 mongoc_cleanup();
105
106 return 0;
107}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

5

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

6
mkdir build && cd build
7
cmake ../
8
cmake --build .
9
./atlas-vector-search-quick-start
1New search index named vector_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3vector_index is ready for querying.
1

For detailed installation instructions, refer to the MongoDB C++ Driver documentation.

2
mkdir query-quick-start
3
cd query-quick-start
touch CMakeLists.txt

Copy and paste the following lines into the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.30)
project(query_quick_start)
set(CMAKE_CXX_STANDARD 17)
# You must use mongocxx driver version 3.11.0 or later to
# create a vector index.
find_package(mongocxx REQUIRED)
find_package(bsoncxx REQUIRED)
add_executable(query_quick_start
vector_index.cpp
)
target_link_libraries(query_quick_start PRIVATE mongo::mongocxx_shared)
target_link_libraries(query_quick_start PRIVATE mongo::bsoncxx_shared)
4

Create a file named vector_index.cpp. Copy and paste the following code into the file.

vector_index.cpp
1#include <bsoncxx/builder/basic/document.hpp>
2#include <iostream>
3#include <mongocxx/client.hpp>
4#include <mongocxx/instance.hpp>
5#include <mongocxx/search_index_view.hpp>
6#include <mongocxx/uri.hpp>
7#include <thread>
8
9using bsoncxx::builder::basic::kvp;
10using bsoncxx::builder::basic::make_array;
11using bsoncxx::builder::basic::make_document;
12
13int main() {
14 try {
15 mongocxx::instance inst{};
16
17 // Replace the placeholder with your connection string
18 const auto uri = mongocxx::uri{"<connection-string>"};
19
20 // Connect to your cluster
21 mongocxx::client conn{uri};
22 auto db = conn["sample_mflix"];
23 auto collection = db["embedded_movies"];
24
25 auto siv = collection.search_indexes();
26 std::string name = "vector_index";
27 auto type = "vectorSearch";
28 auto definition = make_document(
29 kvp("fields",
30 make_array(make_document(
31 kvp("type", "vector"), kvp("path", "plot_embedding_voyage_3_large"),
32 kvp("numDimensions", 2048), kvp("similarity", "dotProduct"),
33 kvp("quantization", "scalar")))));
34 auto model =
35 mongocxx::search_index_model(name, definition.view()).type(type);
36 siv.create_one(model);
37 std::cout << "New search index named " << name << " is building."
38 << std::endl;
39
40 // Polling for index status
41 std::cout << "Polling to check if the index is ready. This may take up to "
42 "a minute."
43 << std::endl;
44 bool queryable = false;
45 while (!queryable) {
46 auto indexes = siv.list();
47 for (const auto& index : indexes) {
48 if (index["name"].get_value() == name) {
49 queryable = index["queryable"].get_bool();
50 }
51 }
52 if (!queryable) {
53 std::this_thread::sleep_for(std::chrono::seconds(5));
54 }
55 }
56 std::cout << name << " is ready for querying." << std::endl;
57 } catch (const std::exception& e) {
58 std::cout << "Exception: " << e.what() << std::endl;
59 }
60 return 0;
61}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

5

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

6
mkdir build && cd build
7
cmake ../
8
cmake --build .
9
./query_quick_start
1New search index named vector_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3vector_index is ready for querying.
1

In your terminal, run the following commands:

mkdir query-quick-start
cd query-quick-start
dotnet new console
2
dotnet add package MongoDB.Driver

For more detailed installation instructions, see the MongoDB .NET/C# Driver documentation.

3

Create a file named IndexService.cs. Copy and paste the following code into the file.

IndexService.cs
1namespace query_quick_start;
2
3using MongoDB.Bson;
4using MongoDB.Driver;
5using System;
6using System.Threading;
7
8public class IndexService
9{
10 // Replace the placeholder with your connection string
11 private const string MongoConnectionString = "<connectionString>";
12 public void CreateVectorIndex()
13 {
14 try
15 {
16 // Connect to your cluster
17 var client = new MongoClient(MongoConnectionString);
18 var database = client.GetDatabase("sample_mflix");
19 var collection = database.GetCollection<BsonDocument>("embedded_movies");
20
21 var searchIndexView = collection.SearchIndexes;
22 var name = "vector_index";
23
24 var model = new CreateVectorSearchIndexModel<Movie>(
25 m => m.PlotEmbedding,
26 name,
27 VectorSimilarity.DotProduct,
28 2048)
29 {
30 Quantization = VectorQuantization.Scalar
31 };
32
33 searchIndexView.CreateOne(model);
34 Console.WriteLine($"New search index named {name} is building.");
35
36 // Polling for index status
37 Console.WriteLine("Polling to check if the index is ready. This may take up to a minute.");
38 bool queryable = false;
39 while (!queryable)
40 {
41 var indexes = searchIndexView.List();
42 foreach (var index in indexes.ToEnumerable())
43 {
44 if (index["name"] == name)
45 {
46 queryable = index["queryable"].AsBoolean;
47 }
48 }
49 if (!queryable)
50 {
51 Thread.Sleep(5000);
52 }
53 }
54 Console.WriteLine($"{name} is ready for querying.");
55 }
56 catch (Exception e)
57 {
58 Console.WriteLine($"Exception: {e.Message}");
59 }
60 }
61}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
Program.cs
using query_quick_start;
var indexService = new IndexService();
indexService.CreateVectorIndex();
6
dotnet run query-quick-start.csproj
1New search index named vector_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3vector_index is ready for querying.
1

Select one of the following tabs, depending on your package manager:

If you are using Maven, add the following dependencies to the dependencies array in your project's pom.xml file:

pom.xml
<dependencies>
<!-- MongoDB Java Sync Driver v5.2.0 or later -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>[5.2.0,)</version>
</dependency>
</dependencies>
2

For more detailed installation instructions and version compatibility, see the MongoDB Java Driver documentation.

3
VectorIndex.java
1import com.mongodb.client.MongoClient;
2import com.mongodb.client.MongoClients;
3import com.mongodb.client.MongoCollection;
4import com.mongodb.client.MongoDatabase;
5import com.mongodb.client.model.SearchIndexModel;
6import com.mongodb.client.model.SearchIndexType;
7import org.bson.Document;
8import org.bson.conversions.Bson;
9
10import java.util.Collections;
11import java.util.List;
12
13public class VectorIndex {
14
15 public static void main(String[] args) {
16
17 // Replace the placeholder with your connection string
18 String uri = "<connectionString>";
19
20 // Connect to your cluster
21 try (MongoClient mongoClient = MongoClients.create(uri)) {
22
23 // Set the namespace
24 MongoDatabase database = mongoClient.getDatabase("sample_mflix");
25 MongoCollection<Document> collection = database.getCollection("embedded_movies");
26
27 // Define the index details
28 String indexName = "vector_index";
29 Bson definition = new Document(
30 "fields",
31 Collections.singletonList(
32 new Document("type", "vector")
33 .append("path", "plot_embedding_voyage_3_large")
34 .append("numDimensions", 2048)
35 .append("similarity", "dotProduct")
36 .append("quantization", "scalar")));
37
38 // Define the index model
39 SearchIndexModel indexModel = new SearchIndexModel(
40 indexName,
41 definition,
42 SearchIndexType.vectorSearch());
43
44 // Create the index using the defined model
45 List<String> result = collection.createSearchIndexes(Collections.singletonList(indexModel));
46 System.out.println("Successfully created vector index named: " + result.get(0));
47 System.out.println("It may take up to a minute for the index to leave the BUILDING status and become queryable.");
48
49 // Wait for index to build and become queryable
50 System.out.println("Polling to confirm the index has left the BUILDING status.");
51 // No special handling in case of a timeout. Custom handling can be implemented.
52 waitForIndex(collection, indexName);
53 }
54 }
55
56 /**
57 * Polls the collection to check whether the specified index is ready to query.
58 */
59 public static <T> boolean waitForIndex(final MongoCollection<T> collection, final String indexName) {
60 long startTime = System.nanoTime();
61 long timeoutNanos = TimeUnit.SECONDS.toNanos(60);
62 while (System.nanoTime() - startTime < timeoutNanos) {
63 Document indexRecord = StreamSupport.stream(collection.listSearchIndexes().spliterator(), false)
64 .filter(index -> indexName.equals(index.getString("name")))
65 .findAny().orElse(null);
66 if (indexRecord != null) {
67 if ("FAILED".equals(indexRecord.getString("status"))) {
68 throw new RuntimeException("Search index has FAILED status.");
69 }
70 if (indexRecord.getBoolean("queryable")) {
71 System.out.println(indexName + " index is ready to query");
72 return true;
73 }
74 }
75 try {
76 Thread.sleep(100); // busy-wait, avoid in production
77 } catch (InterruptedException e) {
78 Thread.currentThread().interrupt();
79 throw new RuntimeException(e);
80 }
81 }
82 return false;
83 }
84}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
javac VectorIndex.java
java VectorIndex
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

For more detailed installation instructions and version compatibility, see the MongoDB Kotlin Coroutine Driver documentation.

2

Create a file named VectorIndex.kt. Copy and paste the following code into the file.

VectorIndex.kt
1import com.mongodb.MongoException
2import com.mongodb.client.model.SearchIndexModel
3import com.mongodb.client.model.SearchIndexType
4import com.mongodb.kotlin.client.coroutine.MongoClient
5import kotlinx.coroutines.delay
6import kotlinx.coroutines.flow.toList
7import org.bson.Document
8import kotlinx.coroutines.runBlocking
9
10fun main() {
11 // Replace the placeholder with your MongoDB deployment's connection string
12 val uri = "<connection-string>"
13 val mongoClient = MongoClient.create(uri)
14 val database = mongoClient.getDatabase("sample_mflix")
15 val collection = database.getCollection<Document>("embedded_movies")
16 val indexName = "vector_index"
17 val searchIndexModel = SearchIndexModel(
18 indexName,
19 Document(
20 "fields",
21 listOf(
22 Document("type", "vector")
23 .append("path", "plot_embedding_voyage_3_large")
24 .append("numDimensions", 2048)
25 .append("similarity", "dotProduct")
26 .append("quantization", "scalar")
27 )
28 ),
29 SearchIndexType.vectorSearch()
30 )
31
32 runBlocking {
33 try {
34 collection.createSearchIndexes(listOf(searchIndexModel))
35 .collect { result ->
36 println("New search index named $result is building.")
37 }
38
39 // Polling to check if the index is queryable
40 println("Polling to check if the index is ready. This may take up to a minute.")
41 var isQueryable = false
42 while (!isQueryable) {
43 delay(5000L) // Poll every 5 seconds
44
45 val indexes = collection.listSearchIndexes().toList()
46 isQueryable = indexes.any { index ->
47 index.getString("name") == indexName && index.getBoolean("queryable")
48 }
49 if (isQueryable) {
50 println("$indexName is ready for querying.")
51 }
52 }
53 } catch (me: MongoException) {
54 System.err.println("An error occurred: $me")
55 }
56 }
57 mongoClient.close()
58}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4

The output should resemble the following:

New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1
npm install mongodb

Tip

The examples on this page assume your project manages modules as CommonJS modules. If you're using ES modules, instead, you must modify the import syntax.

2

Create a file named vector-index.js. Copy and paste the following code into the file.

vector-index.js
1const { MongoClient } = require("mongodb");
2
3// connect to your deployment
4const uri = "<connectionString>";
5
6const client = new MongoClient(uri);
7
8async function run() {
9 try {
10 const database = client.db("sample_mflix");
11 const collection = database.collection("embedded_movies");
12
13 // define your MongoDB Vector Search index
14 const index = {
15 name: "vector_index",
16 type: "vectorSearch",
17 definition: {
18 "fields": [
19 {
20 "type": "vector",
21 "numDimensions": 2048,
22 "path": "plot_embedding_voyage_3_large",
23 "similarity": "dotProduct",
24 "quantization": "scalar"
25 }
26 ]
27 }
28 }
29
30 // run the helper method
31 const result = await collection.createSearchIndex(index);
32 console.log(`New search index named ${result} is building.`);
33
34 // wait for the index to be ready to query
35 console.log("Polling to check if the index is ready. This may take up to a minute.")
36 let isQueryable = false;
37 while (!isQueryable) {
38 const cursor = collection.listSearchIndexes();
39 for await (const index of cursor) {
40 if (index.name === result) {
41 if (index.queryable) {
42 console.log(`${result} is ready for querying.`);
43 isQueryable = true;
44 } else {
45 await new Promise(resolve => setTimeout(resolve, 5000));
46 }
47 }
48 }
49 }
50 } finally {
51 await client.close();
52 }
53}
54run().catch(console.dir);

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
node vector-index.js
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

For detailed installation instructions, see the MongoDB PHP Library documentation.

2

Create a file named vector-index.php. Copy and paste the following code into the file.

vector-index.php
1<?php
2
3require 'vendor/autoload.php';
4
5// Replace the placeholder with your connection string
6$uri = "<connectionString>";
7$client = new MongoDB\Client($uri);
8$collection = $client->sample_mflix->embedded_movies;
9$indexName = "vector_index";
10try {
11 $result = $collection->createSearchIndexes(
12 [[
13 'name' => $indexName,
14 'type' => 'vectorSearch',
15 'definition' => [
16 'fields' => [[
17 'type' => 'vector',
18 'path' => 'plot_embedding_voyage_3_large',
19 'numDimensions' => 2048,
20 'similarity' => 'dotProduct',
21 'quantization' => 'scalar'
22 ]]
23 ],
24 ]]
25 );
26 echo "New search index named $result[0] is building." .PHP_EOL;
27
28 // Polling for the index to become queryable
29 echo "Polling to check if the index is ready. This may take up to a minute." .PHP_EOL;
30 $isIndexQueryable = false;
31 while (!$isIndexQueryable) {
32 // List the search indexes
33 $searchIndexes = $collection->listSearchIndexes();
34 // Check if the index is present and queryable
35 foreach ($searchIndexes as $index) {
36 if ($index->name === $indexName) {
37 $isIndexQueryable = $index->queryable;
38 }
39 }
40 if (!$isIndexQueryable) {
41 sleep(5); // Wait for 5 seconds before polling again
42 }
43 }
44 echo "$indexName is ready for querying." .PHP_EOL;
45}
46catch (MongoDB\Driver\Exception\Exception $e) {
47 print 'Error creating the index: ' .$e->getMessage() .PHP_EOL;
48}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
php vector-index.php
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1
pip install pymongo

For more detailed installation instructions, see the MongoDB Python Driver documentation.

2

Create a file named vector-index.py. Copy and paste the following code into the file.

vector-index.py
1from pymongo.mongo_client import MongoClient
2from pymongo.operations import SearchIndexModel
3import time
4
5# Connect to your deployment
6uri = "<connectionString>"
7client = MongoClient(uri)
8
9# Access your database and collection
10database = client["sample_mflix"]
11collection = database["embedded_movies"]
12
13# Create your index model, then create the search index
14search_index_model = SearchIndexModel(
15 definition={
16 "fields": [
17 {
18 "type": "vector",
19 "path": "plot_embedding_voyage_3_large",
20 "numDimensions": 2048,
21 "similarity": "dotProduct",
22 "quantization": "scalar"
23 }
24 ]
25 },
26 name="vector_index",
27 type="vectorSearch"
28)
29
30result = collection.create_search_index(model=search_index_model)
31print("New search index named " + result + " is building.")
32
33# Wait for initial sync to complete
34print("Polling to check if the index is ready. This may take up to a minute.")
35predicate=None
36if predicate is None:
37 predicate = lambda index: index.get("queryable") is True
38
39while True:
40 indices = list(collection.list_search_indexes(result))
41 if len(indices) and predicate(indices[0]):
42 break
43 time.sleep(5)
44print(result + " is ready for querying.")
45
46client.close()

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
python vector-index.py
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1
  1. If you don't already have a Gemfile for your project, run the following command from your project directory to generate one:

    bundle init
  2. Add the mongo gem to your Gemfile:

    Gemfile
    gem "mongo"
  3. Run the following command to install the dependency:

    bundle install

This installs the latest version of the Ruby driver. For alternate installation instructions and version compatibility, see the MongoDB Ruby Driver documentation.

2
3
vector_index.rb
1require 'mongo'
2require 'json'
3
4uri = "<connection-string>"
5
6begin
7 # Connect to the MongoDB client
8 client = Mongo::Client.new(uri, database: 'sample_mflix')
9
10 # Set the namespace
11 db = client.database
12 collection = db[:embedded_movies]
13
14 # Define the Vector Search index definition
15 index_definition = {
16 fields: [
17 {
18 type: "vector",
19 path: "plot_embedding_voyage_3_large",
20 numDimensions: 2048,
21 similarity: "dotProduct"
22 }
23 ]
24 }
25
26 # Create the index using `create_one`
27 index_name = collection.search_indexes.create_one(
28 index_definition,
29 name: 'vector_index',
30 type: 'vectorSearch'
31 )
32
33 puts "Vector search index created successfully: #{index_name}"
34
35rescue Mongo::Error::NoServerAvailable => e
36 # Handle MongoDB server connection issues
37 puts "Failed to connect to MongoDB: #{e.message}"
38
39rescue Mongo::Error::OperationFailure => e
40 # Handle MongoDB operation failure issues
41 puts "Failed to perform operation: #{e.message}"
42
43rescue Mongo::Error => e
44 # Handle general MongoDB-related errors
45 puts "A MongoDB error occurred: #{e.message}"
46
47rescue StandardError => e
48 # Handle any other kinds of errors
49 puts "A general error occurred: #{e.message}"
50
51ensure
52 # Ensure the client is closed
53 client&.close
54 puts "MongoDB client closed."
55end
4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
bundle exec ruby vector_index.rb
1

For more detailed installation instructions, see the MongoDB Rust Driver documentation.

2

In the /src directory of your project, create a file named vector_index.rs. Copy and paste the following code into the file.

vector_index.rs
1use std::time::Duration;
2use futures::TryStreamExt;
3use mongodb::{bson::{doc, Document}, Client, Collection, SearchIndexModel};
4use mongodb::SearchIndexType::VectorSearch;
5use tokio::time::sleep;
6
7pub(crate) async fn vector_index() {
8 // Replace the placeholder with your connection string
9 let uri = "<connection_string>";
10
11 // Create a new client and connect to the server
12 let client = Client::with_uri_str(uri).await.unwrap();
13
14 // Get a handle on the movies collection
15 let database = client.database("sample_mflix");
16 let my_coll: Collection<Document> = database.collection("embedded_movies");
17
18 let index_name = "vector_index";
19 let search_index_def = SearchIndexModel::builder()
20 .definition(doc! {
21 "fields": vec! {doc! {
22 "type": "vector",
23 "path": "plot_embedding_voyage_3_large",
24 "numDimensions": 2048,
25 "similarity": "dotProduct",
26 "quantization": "scalar"
27 }}
28 })
29 .name(index_name.to_string())
30 .index_type(VectorSearch)
31 .build();
32
33 let models = vec![search_index_def];
34 match my_coll.create_search_indexes(models).await {
35 Err(e) => {
36 eprintln!("There was an error creating the search index: {}", e);
37 std::process::exit(1)
38 }
39 Ok(names) => {
40 println!("New search index named {} is building.", names[0]);
41 }
42 }
43
44 // Polling for the index to become queryable
45 println!("Polling to check if the index is ready. This may take up to a minute.");
46 let mut is_index_queryable = false;
47 while !is_index_queryable {
48 // List the search indexes
49 let mut search_indexes = my_coll.list_search_indexes().await.unwrap();
50 // Check if the index is present and queryable
51 while let Some(index) = search_indexes.try_next().await.unwrap() {
52 if index.get_str("name") == Ok(index_name) {
53 is_index_queryable = index.get_bool("queryable").unwrap_or(false);
54 }
55 }
56 if !is_index_queryable {
57 sleep(Duration::from_secs(5)).await; // Wait for 5 seconds before polling again
58 }
59 }
60 println!("{} is ready for querying.", index_name);
61}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
mod vector_index;
#[tokio::main]
async fn main() {
vector_index::vector_index().await;
}
5
cargo run
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

For installation instructions based on your environment and the version of Scala you are using, refer to the MongoDB Scala Driver documentation.

2

For this quick start, we create a project named quick-start, by using sbt.

sbt new scala/hello-world.g8

When prompted, name the application quick-start.

3

Copy and paste the following code into the file.

VectorIndex.scala
1import org.mongodb.scala._
2import org.mongodb.scala.model._
3import com.mongodb.client.model.SearchIndexType
4
5class VectorIndex {
6 def createIndex(): Unit = {
7 val collection =
8 MongoClient("<connectionString>")
9 .getDatabase("sample_mflix")
10 .getCollection("embedded_movies")
11 val indexName = "vector_index"
12 val indexNameAsOption = Option(indexName)
13 val indexDefinition = Document(
14 "fields" -> List(
15 Document(
16 "type" -> "vector",
17 "path" -> "plot_embedding_voyage_3_large",
18 "numDimensions" -> 2048,
19 "similarity" -> "dotProduct",
20 "quantization" -> "scalar"
21 )
22 )
23 )
24 val indexType = Option(SearchIndexType.vectorSearch())
25 val indexModel: SearchIndexModel = SearchIndexModel(
26 indexNameAsOption, indexDefinition, indexType
27 )
28 collection.createSearchIndexes(List(indexModel)).foreach { doc => println(s"New search index named $doc is building.") }
29 Thread.sleep(2000)
30 println("Polling to check if the index is ready. This may take up to a minute.")
31 var indexReady = false
32 while (!indexReady) {
33 val searchIndexes = collection.listSearchIndexes()
34 searchIndexes.foreach { current =>
35 val document = current.toBsonDocument()
36 val name = document.get("name").asString().getValue
37 val queryable = document.get("queryable").asBoolean().getValue
38 if (name == indexName && queryable) {
39 indexReady = true
40 }
41 }
42 if (!indexReady) {
43 Thread.sleep(5000)
44 }
45 }
46 println(s"$indexName is ready for querying.")
47 }
48}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
object Main extends App {
private val indexInstance = new VectorIndex
indexInstance.createIndex()
}
6

There are many tools and environments in which Scala runs. In this example, we run the new Scala project by starting the sbt server with the sbt command, then typing ~run.

sbt:quick-start> ~run
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

Example

use sample_mflix
switched to db sample_mflix
2
1db.embedded_movies.createSearchIndex(
2 "vector_index",
3 "vectorSearch",
4 {
5 "fields": [
6 {
7 "type": "vector",
8 "path": "plot_embedding_voyage_3_large",
9 "numDimensions": 2048,
10 "similarity": "dotProduct",
11 "quantization": "scalar"
12 }
13 ]
14 }
15);

This index definition:

1

For detailed installation instructions, refer to the MongoDB C Driver documentation.

2
mkdir query-quick-start
3
cd query-quick-start
touch CMakeLists.txt

Copy and paste the following lines into the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.30)
project(atlas-vector-search-quick-start)
# Specify the minimum version for creating a vector index.
find_package (mongoc-1.0 1.28.0 REQUIRED)
add_executable(atlas-vector-search-quick-start
vector_index.c
)
target_link_libraries (atlas-vector-search-quick-start PRIVATE mongo::mongoc_shared)
4

Create a file named vector_index.c. Copy and paste the following code into the file.

vector_index.c
1#include <bson/bson.h>
2#include <mongoc/mongoc.h>
3#include <stdio.h>
4
5int main(void) {
6 mongoc_client_t *client;
7 mongoc_collection_t *collection;
8 bson_error_t error;
9 char database_name[] = "sample_mflix";
10 char collection_name[] = "embedded_movies";
11 char index_name[] = "vector_index";
12
13 mongoc_init();
14
15 // Replace the placeholder with your connection string
16 client = mongoc_client_new("<connection-string>");
17
18 // Connect to your cluster
19 collection = mongoc_client_get_collection (client, database_name, collection_name);
20
21 bson_t cmd;
22 // Create search index command.
23 {
24 char *cmd_str = bson_strdup_printf (
25 BSON_STR ({
26 "createSearchIndexes" : "%s",
27 "indexes" : [{
28 "definition": {
29 "fields": [{
30 "type": "vector",
31 "path": "plot_embedding_voyage_3_large",
32 "numDimensions": 2048,
33 "similarity": "dotProduct",
34 "quantization": "scalar"
35 }]
36 },
37 "name": "%s",
38 "type": "vectorSearch"
39 }]
40 }),
41 collection_name, index_name);
42 if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
43 printf("Failed to initialize BSON: %s\n", error.message);
44 bson_free(cmd_str);
45 return 1;
46 }
47 bson_free (cmd_str);
48 }
49 if (!mongoc_collection_command_simple (collection, &cmd, NULL /* read_prefs */, NULL /* reply */, &error)) {
50 bson_destroy (&cmd);
51 printf ("Failed to run createSearchIndexes: %s", error.message);
52 return 1;
53 } else {
54 printf ("New search index named %s is building.\n", index_name);
55 bson_destroy (&cmd);
56 }
57
58 // Polling for index status
59 printf("Polling to check if the index is ready. This may take up to a minute.\n");
60 int queryable = 0;
61 while (!queryable) {
62 const char *pipeline_str = "{\"pipeline\": [{\"$listSearchIndexes\": {}}]}";
63 bson_t pipeline;
64 if (!bson_init_from_json(&pipeline, pipeline_str, -1, &error)) {
65 printf("Failed to initialize pipeline BSON: %s\n", error.message);
66 break; // Exit the loop on error
67 }
68 mongoc_cursor_t *cursor = mongoc_collection_aggregate(collection, MONGOC_QUERY_NONE, &pipeline, NULL, NULL);
69 const bson_t *got;
70 // Check if the cursor returns any documents
71 int found_index = 0;
72 while (mongoc_cursor_next(cursor, &got)) {
73 bson_iter_t iter;
74 if (bson_iter_init(&iter, got) && bson_iter_find(&iter, "name")) {
75 const char *name = bson_iter_utf8(&iter, NULL);
76 if (strcmp(name, index_name) == 0) {
77 found_index = 1; // Index found
78 bson_iter_find(&iter, "queryable");
79 queryable = bson_iter_bool(&iter);
80 break; // Exit the loop since we found the index
81 }
82 }
83 }
84 if (mongoc_cursor_error(cursor, &error)) {
85 printf("Failed to run $listSearchIndexes: %s\n", error.message);
86 break; // Exit the loop on error
87 }
88 if (!found_index) {
89 printf("Index %s not found yet. Retrying...\n", index_name);
90 }
91 bson_destroy(&pipeline);
92 mongoc_cursor_destroy(cursor);
93 sleep(5); // Sleep for 5 seconds before checking again
94 }
95 if (queryable) {
96 printf("%s is ready for querying.\n", index_name);
97 } else {
98 printf("Error occurred or index not found.\n");
99 }
100
101 // Cleanup
102 mongoc_collection_destroy(collection);
103 mongoc_client_destroy(client);
104 mongoc_cleanup();
105
106 return 0;
107}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

5

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

6
mkdir build && cd build
7
cmake ../
8
cmake --build .
9
./atlas-vector-search-quick-start
1New search index named vector_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3vector_index is ready for querying.
1

For detailed installation instructions, refer to the MongoDB C++ Driver documentation.

2
mkdir query-quick-start
3
cd query-quick-start
touch CMakeLists.txt

Copy and paste the following lines into the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.30)
project(query_quick_start)
set(CMAKE_CXX_STANDARD 17)
# You must use mongocxx driver version 3.11.0 or later to
# create a vector index.
find_package(mongocxx REQUIRED)
find_package(bsoncxx REQUIRED)
add_executable(query_quick_start
vector_index.cpp
)
target_link_libraries(query_quick_start PRIVATE mongo::mongocxx_shared)
target_link_libraries(query_quick_start PRIVATE mongo::bsoncxx_shared)
4

Create a file named vector_index.cpp. Copy and paste the following code into the file.

vector_index.cpp
1#include <bsoncxx/builder/basic/document.hpp>
2#include <iostream>
3#include <mongocxx/client.hpp>
4#include <mongocxx/instance.hpp>
5#include <mongocxx/search_index_view.hpp>
6#include <mongocxx/uri.hpp>
7#include <thread>
8
9using bsoncxx::builder::basic::kvp;
10using bsoncxx::builder::basic::make_array;
11using bsoncxx::builder::basic::make_document;
12
13int main() {
14 try {
15 mongocxx::instance inst{};
16
17 // Replace the placeholder with your connection string
18 const auto uri = mongocxx::uri{"<connection-string>"};
19
20 // Connect to your cluster
21 mongocxx::client conn{uri};
22 auto db = conn["sample_mflix"];
23 auto collection = db["embedded_movies"];
24
25 auto siv = collection.search_indexes();
26 std::string name = "vector_index";
27 auto type = "vectorSearch";
28 auto definition = make_document(
29 kvp("fields",
30 make_array(make_document(
31 kvp("type", "vector"), kvp("path", "plot_embedding_voyage_3_large"),
32 kvp("numDimensions", 2048), kvp("similarity", "dotProduct"),
33 kvp("quantization", "scalar")))));
34 auto model =
35 mongocxx::search_index_model(name, definition.view()).type(type);
36 siv.create_one(model);
37 std::cout << "New search index named " << name << " is building."
38 << std::endl;
39
40 // Polling for index status
41 std::cout << "Polling to check if the index is ready. This may take up to "
42 "a minute."
43 << std::endl;
44 bool queryable = false;
45 while (!queryable) {
46 auto indexes = siv.list();
47 for (const auto& index : indexes) {
48 if (index["name"].get_value() == name) {
49 queryable = index["queryable"].get_bool();
50 }
51 }
52 if (!queryable) {
53 std::this_thread::sleep_for(std::chrono::seconds(5));
54 }
55 }
56 std::cout << name << " is ready for querying." << std::endl;
57 } catch (const std::exception& e) {
58 std::cout << "Exception: " << e.what() << std::endl;
59 }
60 return 0;
61}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

5

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

6
mkdir build && cd build
7
cmake ../
8
cmake --build .
9
./query_quick_start
1New search index named vector_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3vector_index is ready for querying.

In this section, you create a MongoDB Vector Search index on sample data that you load into your Atlas cluster or a deployment hosted on your local computer:

1

In your terminal, run the following commands:

mkdir query-quick-start
cd query-quick-start
dotnet new console
2
dotnet add package MongoDB.Driver

For more detailed installation instructions, see the MongoDB .NET/C# Driver documentation.

3

Create a file named IndexService.cs. Copy and paste the following code into the file.

IndexService.cs
1namespace query_quick_start;
2
3using MongoDB.Bson;
4using MongoDB.Driver;
5using System;
6using System.Threading;
7
8public class IndexService
9{
10 // Replace the placeholder with your connection string
11 private const string MongoConnectionString = "<connectionString>";
12 public void CreateVectorIndex()
13 {
14 try
15 {
16 // Connect to your cluster
17 var client = new MongoClient(MongoConnectionString);
18 var database = client.GetDatabase("sample_mflix");
19 var collection = database.GetCollection<BsonDocument>("embedded_movies");
20
21 var searchIndexView = collection.SearchIndexes;
22 var name = "vector_index";
23
24 var model = new CreateVectorSearchIndexModel<Movie>(
25 m => m.PlotEmbedding,
26 name,
27 VectorSimilarity.DotProduct,
28 2048)
29 {
30 Quantization = VectorQuantization.Scalar
31 };
32
33 searchIndexView.CreateOne(model);
34 Console.WriteLine($"New search index named {name} is building.");
35
36 // Polling for index status
37 Console.WriteLine("Polling to check if the index is ready. This may take up to a minute.");
38 bool queryable = false;
39 while (!queryable)
40 {
41 var indexes = searchIndexView.List();
42 foreach (var index in indexes.ToEnumerable())
43 {
44 if (index["name"] == name)
45 {
46 queryable = index["queryable"].AsBoolean;
47 }
48 }
49 if (!queryable)
50 {
51 Thread.Sleep(5000);
52 }
53 }
54 Console.WriteLine($"{name} is ready for querying.");
55 }
56 catch (Exception e)
57 {
58 Console.WriteLine($"Exception: {e.Message}");
59 }
60 }
61}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
Program.cs
using query_quick_start;
var indexService = new IndexService();
indexService.CreateVectorIndex();
6
dotnet run query-quick-start.csproj
1New search index named vector_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3vector_index is ready for querying.
1

Select one of the following tabs, depending on your package manager:

If you are using Maven, add the following dependencies to the dependencies array in your project's pom.xml file:

pom.xml
<dependencies>
<!-- MongoDB Java Sync Driver v5.2.0 or later -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>[5.2.0,)</version>
</dependency>
</dependencies>
2

For more detailed installation instructions and version compatibility, see the MongoDB Java Driver documentation.

3
VectorIndex.java
1import com.mongodb.client.MongoClient;
2import com.mongodb.client.MongoClients;
3import com.mongodb.client.MongoCollection;
4import com.mongodb.client.MongoDatabase;
5import com.mongodb.client.model.SearchIndexModel;
6import com.mongodb.client.model.SearchIndexType;
7import org.bson.Document;
8import org.bson.conversions.Bson;
9
10import java.util.Collections;
11import java.util.List;
12
13public class VectorIndex {
14
15 public static void main(String[] args) {
16
17 // Replace the placeholder with your connection string
18 String uri = "<connectionString>";
19
20 // Connect to your cluster
21 try (MongoClient mongoClient = MongoClients.create(uri)) {
22
23 // Set the namespace
24 MongoDatabase database = mongoClient.getDatabase("sample_mflix");
25 MongoCollection<Document> collection = database.getCollection("embedded_movies");
26
27 // Define the index details
28 String indexName = "vector_index";
29 Bson definition = new Document(
30 "fields",
31 Collections.singletonList(
32 new Document("type", "vector")
33 .append("path", "plot_embedding_voyage_3_large")
34 .append("numDimensions", 2048)
35 .append("similarity", "dotProduct")
36 .append("quantization", "scalar")));
37
38 // Define the index model
39 SearchIndexModel indexModel = new SearchIndexModel(
40 indexName,
41 definition,
42 SearchIndexType.vectorSearch());
43
44 // Create the index using the defined model
45 List<String> result = collection.createSearchIndexes(Collections.singletonList(indexModel));
46 System.out.println("Successfully created vector index named: " + result.get(0));
47 System.out.println("It may take up to a minute for the index to leave the BUILDING status and become queryable.");
48
49 // Wait for index to build and become queryable
50 System.out.println("Polling to confirm the index has left the BUILDING status.");
51 // No special handling in case of a timeout. Custom handling can be implemented.
52 waitForIndex(collection, indexName);
53 }
54 }
55
56 /**
57 * Polls the collection to check whether the specified index is ready to query.
58 */
59 public static <T> boolean waitForIndex(final MongoCollection<T> collection, final String indexName) {
60 long startTime = System.nanoTime();
61 long timeoutNanos = TimeUnit.SECONDS.toNanos(60);
62 while (System.nanoTime() - startTime < timeoutNanos) {
63 Document indexRecord = StreamSupport.stream(collection.listSearchIndexes().spliterator(), false)
64 .filter(index -> indexName.equals(index.getString("name")))
65 .findAny().orElse(null);
66 if (indexRecord != null) {
67 if ("FAILED".equals(indexRecord.getString("status"))) {
68 throw new RuntimeException("Search index has FAILED status.");
69 }
70 if (indexRecord.getBoolean("queryable")) {
71 System.out.println(indexName + " index is ready to query");
72 return true;
73 }
74 }
75 try {
76 Thread.sleep(100); // busy-wait, avoid in production
77 } catch (InterruptedException e) {
78 Thread.currentThread().interrupt();
79 throw new RuntimeException(e);
80 }
81 }
82 return false;
83 }
84}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
javac VectorIndex.java
java VectorIndex
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

For more detailed installation instructions and version compatibility, see the MongoDB Kotlin Coroutine Driver documentation.

2

Create a file named VectorIndex.kt. Copy and paste the following code into the file.

VectorIndex.kt
1import com.mongodb.MongoException
2import com.mongodb.client.model.SearchIndexModel
3import com.mongodb.client.model.SearchIndexType
4import com.mongodb.kotlin.client.coroutine.MongoClient
5import kotlinx.coroutines.delay
6import kotlinx.coroutines.flow.toList
7import org.bson.Document
8import kotlinx.coroutines.runBlocking
9
10fun main() {
11 // Replace the placeholder with your MongoDB deployment's connection string
12 val uri = "<connection-string>"
13 val mongoClient = MongoClient.create(uri)
14 val database = mongoClient.getDatabase("sample_mflix")
15 val collection = database.getCollection<Document>("embedded_movies")
16 val indexName = "vector_index"
17 val searchIndexModel = SearchIndexModel(
18 indexName,
19 Document(
20 "fields",
21 listOf(
22 Document("type", "vector")
23 .append("path", "plot_embedding_voyage_3_large")
24 .append("numDimensions", 2048)
25 .append("similarity", "dotProduct")
26 .append("quantization", "scalar")
27 )
28 ),
29 SearchIndexType.vectorSearch()
30 )
31
32 runBlocking {
33 try {
34 collection.createSearchIndexes(listOf(searchIndexModel))
35 .collect { result ->
36 println("New search index named $result is building.")
37 }
38
39 // Polling to check if the index is queryable
40 println("Polling to check if the index is ready. This may take up to a minute.")
41 var isQueryable = false
42 while (!isQueryable) {
43 delay(5000L) // Poll every 5 seconds
44
45 val indexes = collection.listSearchIndexes().toList()
46 isQueryable = indexes.any { index ->
47 index.getString("name") == indexName && index.getBoolean("queryable")
48 }
49 if (isQueryable) {
50 println("$indexName is ready for querying.")
51 }
52 }
53 } catch (me: MongoException) {
54 System.err.println("An error occurred: $me")
55 }
56 }
57 mongoClient.close()
58}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4

The output should resemble the following:

New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1
npm install mongodb

Tip

The examples on this page assume your project manages modules as CommonJS modules. If you're using ES modules, instead, you must modify the import syntax.

2

Create a file named vector-index.js. Copy and paste the following code into the file.

vector-index.js
1const { MongoClient } = require("mongodb");
2
3// connect to your deployment
4const uri = "<connectionString>";
5
6const client = new MongoClient(uri);
7
8async function run() {
9 try {
10 const database = client.db("sample_mflix");
11 const collection = database.collection("embedded_movies");
12
13 // define your MongoDB Vector Search index
14 const index = {
15 name: "vector_index",
16 type: "vectorSearch",
17 definition: {
18 "fields": [
19 {
20 "type": "vector",
21 "numDimensions": 2048,
22 "path": "plot_embedding_voyage_3_large",
23 "similarity": "dotProduct",
24 "quantization": "scalar"
25 }
26 ]
27 }
28 }
29
30 // run the helper method
31 const result = await collection.createSearchIndex(index);
32 console.log(`New search index named ${result} is building.`);
33
34 // wait for the index to be ready to query
35 console.log("Polling to check if the index is ready. This may take up to a minute.")
36 let isQueryable = false;
37 while (!isQueryable) {
38 const cursor = collection.listSearchIndexes();
39 for await (const index of cursor) {
40 if (index.name === result) {
41 if (index.queryable) {
42 console.log(`${result} is ready for querying.`);
43 isQueryable = true;
44 } else {
45 await new Promise(resolve => setTimeout(resolve, 5000));
46 }
47 }
48 }
49 }
50 } finally {
51 await client.close();
52 }
53}
54run().catch(console.dir);

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
node vector-index.js
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

For detailed installation instructions, see the MongoDB PHP Library documentation.

2

Create a file named vector-index.php. Copy and paste the following code into the file.

vector-index.php
1<?php
2
3require 'vendor/autoload.php';
4
5// Replace the placeholder with your connection string
6$uri = "<connectionString>";
7$client = new MongoDB\Client($uri);
8$collection = $client->sample_mflix->embedded_movies;
9$indexName = "vector_index";
10try {
11 $result = $collection->createSearchIndexes(
12 [[
13 'name' => $indexName,
14 'type' => 'vectorSearch',
15 'definition' => [
16 'fields' => [[
17 'type' => 'vector',
18 'path' => 'plot_embedding_voyage_3_large',
19 'numDimensions' => 2048,
20 'similarity' => 'dotProduct',
21 'quantization' => 'scalar'
22 ]]
23 ],
24 ]]
25 );
26 echo "New search index named $result[0] is building." .PHP_EOL;
27
28 // Polling for the index to become queryable
29 echo "Polling to check if the index is ready. This may take up to a minute." .PHP_EOL;
30 $isIndexQueryable = false;
31 while (!$isIndexQueryable) {
32 // List the search indexes
33 $searchIndexes = $collection->listSearchIndexes();
34 // Check if the index is present and queryable
35 foreach ($searchIndexes as $index) {
36 if ($index->name === $indexName) {
37 $isIndexQueryable = $index->queryable;
38 }
39 }
40 if (!$isIndexQueryable) {
41 sleep(5); // Wait for 5 seconds before polling again
42 }
43 }
44 echo "$indexName is ready for querying." .PHP_EOL;
45}
46catch (MongoDB\Driver\Exception\Exception $e) {
47 print 'Error creating the index: ' .$e->getMessage() .PHP_EOL;
48}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
php vector-index.php
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1
pip install pymongo

For more detailed installation instructions, see the MongoDB Python Driver documentation.

2

Create a file named vector-index.py. Copy and paste the following code into the file.

vector-index.py
1from pymongo.mongo_client import MongoClient
2from pymongo.operations import SearchIndexModel
3import time
4
5# Connect to your deployment
6uri = "<connectionString>"
7client = MongoClient(uri)
8
9# Access your database and collection
10database = client["sample_mflix"]
11collection = database["embedded_movies"]
12
13# Create your index model, then create the search index
14search_index_model = SearchIndexModel(
15 definition={
16 "fields": [
17 {
18 "type": "vector",
19 "path": "plot_embedding_voyage_3_large",
20 "numDimensions": 2048,
21 "similarity": "dotProduct",
22 "quantization": "scalar"
23 }
24 ]
25 },
26 name="vector_index",
27 type="vectorSearch"
28)
29
30result = collection.create_search_index(model=search_index_model)
31print("New search index named " + result + " is building.")
32
33# Wait for initial sync to complete
34print("Polling to check if the index is ready. This may take up to a minute.")
35predicate=None
36if predicate is None:
37 predicate = lambda index: index.get("queryable") is True
38
39while True:
40 indices = list(collection.list_search_indexes(result))
41 if len(indices) and predicate(indices[0]):
42 break
43 time.sleep(5)
44print(result + " is ready for querying.")
45
46client.close()

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
python vector-index.py
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1
  1. If you don't already have a Gemfile for your project, run the following command from your project directory to generate one:

    bundle init
  2. Add the mongo gem to your Gemfile:

    Gemfile
    gem "mongo"
  3. Run the following command to install the dependency:

    bundle install

This installs the latest version of the Ruby driver. For alternate installation instructions and version compatibility, see the MongoDB Ruby Driver documentation.

2
3
vector_index.rb
1require 'mongo'
2require 'json'
3
4uri = "<connection-string>"
5
6begin
7 # Connect to the MongoDB client
8 client = Mongo::Client.new(uri, database: 'sample_mflix')
9
10 # Set the namespace
11 db = client.database
12 collection = db[:embedded_movies]
13
14 # Define the Vector Search index definition
15 index_definition = {
16 fields: [
17 {
18 type: "vector",
19 path: "plot_embedding_voyage_3_large",
20 numDimensions: 2048,
21 similarity: "dotProduct"
22 }
23 ]
24 }
25
26 # Create the index using `create_one`
27 index_name = collection.search_indexes.create_one(
28 index_definition,
29 name: 'vector_index',
30 type: 'vectorSearch'
31 )
32
33 puts "Vector search index created successfully: #{index_name}"
34
35rescue Mongo::Error::NoServerAvailable => e
36 # Handle MongoDB server connection issues
37 puts "Failed to connect to MongoDB: #{e.message}"
38
39rescue Mongo::Error::OperationFailure => e
40 # Handle MongoDB operation failure issues
41 puts "Failed to perform operation: #{e.message}"
42
43rescue Mongo::Error => e
44 # Handle general MongoDB-related errors
45 puts "A MongoDB error occurred: #{e.message}"
46
47rescue StandardError => e
48 # Handle any other kinds of errors
49 puts "A general error occurred: #{e.message}"
50
51ensure
52 # Ensure the client is closed
53 client&.close
54 puts "MongoDB client closed."
55end
4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
bundle exec ruby vector_index.rb
1

For more detailed installation instructions, see the MongoDB Rust Driver documentation.

2

In the /src directory of your project, create a file named vector_index.rs. Copy and paste the following code into the file.

vector_index.rs
1use std::time::Duration;
2use futures::TryStreamExt;
3use mongodb::{bson::{doc, Document}, Client, Collection, SearchIndexModel};
4use mongodb::SearchIndexType::VectorSearch;
5use tokio::time::sleep;
6
7pub(crate) async fn vector_index() {
8 // Replace the placeholder with your connection string
9 let uri = "<connection_string>";
10
11 // Create a new client and connect to the server
12 let client = Client::with_uri_str(uri).await.unwrap();
13
14 // Get a handle on the movies collection
15 let database = client.database("sample_mflix");
16 let my_coll: Collection<Document> = database.collection("embedded_movies");
17
18 let index_name = "vector_index";
19 let search_index_def = SearchIndexModel::builder()
20 .definition(doc! {
21 "fields": vec! {doc! {
22 "type": "vector",
23 "path": "plot_embedding_voyage_3_large",
24 "numDimensions": 2048,
25 "similarity": "dotProduct",
26 "quantization": "scalar"
27 }}
28 })
29 .name(index_name.to_string())
30 .index_type(VectorSearch)
31 .build();
32
33 let models = vec![search_index_def];
34 match my_coll.create_search_indexes(models).await {
35 Err(e) => {
36 eprintln!("There was an error creating the search index: {}", e);
37 std::process::exit(1)
38 }
39 Ok(names) => {
40 println!("New search index named {} is building.", names[0]);
41 }
42 }
43
44 // Polling for the index to become queryable
45 println!("Polling to check if the index is ready. This may take up to a minute.");
46 let mut is_index_queryable = false;
47 while !is_index_queryable {
48 // List the search indexes
49 let mut search_indexes = my_coll.list_search_indexes().await.unwrap();
50 // Check if the index is present and queryable
51 while let Some(index) = search_indexes.try_next().await.unwrap() {
52 if index.get_str("name") == Ok(index_name) {
53 is_index_queryable = index.get_bool("queryable").unwrap_or(false);
54 }
55 }
56 if !is_index_queryable {
57 sleep(Duration::from_secs(5)).await; // Wait for 5 seconds before polling again
58 }
59 }
60 println!("{} is ready for querying.", index_name);
61}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
mod vector_index;
#[tokio::main]
async fn main() {
vector_index::vector_index().await;
}
5
cargo run
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

For installation instructions based on your environment and the version of Scala you are using, refer to the MongoDB Scala Driver documentation.

2

For this quick start, we create a project named quick-start, by using sbt.

sbt new scala/hello-world.g8

When prompted, name the application quick-start.

3

Copy and paste the following code into the file.

VectorIndex.scala
1import org.mongodb.scala._
2import org.mongodb.scala.model._
3import com.mongodb.client.model.SearchIndexType
4
5class VectorIndex {
6 def createIndex(): Unit = {
7 val collection =
8 MongoClient("<connectionString>")
9 .getDatabase("sample_mflix")
10 .getCollection("embedded_movies")
11 val indexName = "vector_index"
12 val indexNameAsOption = Option(indexName)
13 val indexDefinition = Document(
14 "fields" -> List(
15 Document(
16 "type" -> "vector",
17 "path" -> "plot_embedding_voyage_3_large",
18 "numDimensions" -> 2048,
19 "similarity" -> "dotProduct",
20 "quantization" -> "scalar"
21 )
22 )
23 )
24 val indexType = Option(SearchIndexType.vectorSearch())
25 val indexModel: SearchIndexModel = SearchIndexModel(
26 indexNameAsOption, indexDefinition, indexType
27 )
28 collection.createSearchIndexes(List(indexModel)).foreach { doc => println(s"New search index named $doc is building.") }
29 Thread.sleep(2000)
30 println("Polling to check if the index is ready. This may take up to a minute.")
31 var indexReady = false
32 while (!indexReady) {
33 val searchIndexes = collection.listSearchIndexes()
34 searchIndexes.foreach { current =>
35 val document = current.toBsonDocument()
36 val name = document.get("name").asString().getValue
37 val queryable = document.get("queryable").asBoolean().getValue
38 if (name == indexName && queryable) {
39 indexReady = true
40 }
41 }
42 if (!indexReady) {
43 Thread.sleep(5000)
44 }
45 }
46 println(s"$indexName is ready for querying.")
47 }
48}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
object Main extends App {
private val indexInstance = new VectorIndex
indexInstance.createIndex()
}
6

There are many tools and environments in which Scala runs. In this example, we run the new Scala project by starting the sbt server with the sbt command, then typing ~run.

sbt:quick-start> ~run
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

Open mongosh in a terminal window and connect to your Atlas cluster. For detailed instructions on connecting, see Connect via mongosh.

mongosh "mongodb://localhost:27017"
2

Example

use sample_mflix
switched to db sample_mflix
3

You can create an index of vector type to run queries using vector embeddings.

1db.embedded_movies.createSearchIndex(
2 "vector_index",
3 "vectorSearch",
4 {
5 "fields": [
6 {
7 "type": "vector",
8 "path": "plot_embedding_voyage_3_large",
9 "numDimensions": 2048,
10 "similarity": "dotProduct",
11 "quantization": "scalar"
12 }
13 ]
14 }
15);

This index definition:

1

For detailed installation instructions, refer to the MongoDB C Driver documentation.

2
mkdir query-quick-start
3
cd query-quick-start
touch CMakeLists.txt

Copy and paste the following lines into the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.30)
project(atlas-vector-search-quick-start)
# Specify the minimum version for creating a vector index.
find_package (mongoc-1.0 1.28.0 REQUIRED)
add_executable(atlas-vector-search-quick-start
vector_index.c
)
target_link_libraries (atlas-vector-search-quick-start PRIVATE mongo::mongoc_shared)
4

Create a file named vector_index.c. Copy and paste the following code into the file.

vector_index.c
1#include <bson/bson.h>
2#include <mongoc/mongoc.h>
3#include <stdio.h>
4
5int main(void) {
6 mongoc_client_t *client;
7 mongoc_collection_t *collection;
8 bson_error_t error;
9 char database_name[] = "sample_mflix";
10 char collection_name[] = "embedded_movies";
11 char index_name[] = "vector_index";
12
13 mongoc_init();
14
15 // Replace the placeholder with your connection string
16 client = mongoc_client_new("<connection-string>");
17
18 // Connect to your cluster
19 collection = mongoc_client_get_collection (client, database_name, collection_name);
20
21 bson_t cmd;
22 // Create search index command.
23 {
24 char *cmd_str = bson_strdup_printf (
25 BSON_STR ({
26 "createSearchIndexes" : "%s",
27 "indexes" : [{
28 "definition": {
29 "fields": [{
30 "type": "vector",
31 "path": "plot_embedding_voyage_3_large",
32 "numDimensions": 2048,
33 "similarity": "dotProduct",
34 "quantization": "scalar"
35 }]
36 },
37 "name": "%s",
38 "type": "vectorSearch"
39 }]
40 }),
41 collection_name, index_name);
42 if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
43 printf("Failed to initialize BSON: %s\n", error.message);
44 bson_free(cmd_str);
45 return 1;
46 }
47 bson_free (cmd_str);
48 }
49 if (!mongoc_collection_command_simple (collection, &cmd, NULL /* read_prefs */, NULL /* reply */, &error)) {
50 bson_destroy (&cmd);
51 printf ("Failed to run createSearchIndexes: %s", error.message);
52 return 1;
53 } else {
54 printf ("New search index named %s is building.\n", index_name);
55 bson_destroy (&cmd);
56 }
57
58 // Polling for index status
59 printf("Polling to check if the index is ready. This may take up to a minute.\n");
60 int queryable = 0;
61 while (!queryable) {
62 const char *pipeline_str = "{\"pipeline\": [{\"$listSearchIndexes\": {}}]}";
63 bson_t pipeline;
64 if (!bson_init_from_json(&pipeline, pipeline_str, -1, &error)) {
65 printf("Failed to initialize pipeline BSON: %s\n", error.message);
66 break; // Exit the loop on error
67 }
68 mongoc_cursor_t *cursor = mongoc_collection_aggregate(collection, MONGOC_QUERY_NONE, &pipeline, NULL, NULL);
69 const bson_t *got;
70 // Check if the cursor returns any documents
71 int found_index = 0;
72 while (mongoc_cursor_next(cursor, &got)) {
73 bson_iter_t iter;
74 if (bson_iter_init(&iter, got) && bson_iter_find(&iter, "name")) {
75 const char *name = bson_iter_utf8(&iter, NULL);
76 if (strcmp(name, index_name) == 0) {
77 found_index = 1; // Index found
78 bson_iter_find(&iter, "queryable");
79 queryable = bson_iter_bool(&iter);
80 break; // Exit the loop since we found the index
81 }
82 }
83 }
84 if (mongoc_cursor_error(cursor, &error)) {
85 printf("Failed to run $listSearchIndexes: %s\n", error.message);
86 break; // Exit the loop on error
87 }
88 if (!found_index) {
89 printf("Index %s not found yet. Retrying...\n", index_name);
90 }
91 bson_destroy(&pipeline);
92 mongoc_cursor_destroy(cursor);
93 sleep(5); // Sleep for 5 seconds before checking again
94 }
95 if (queryable) {
96 printf("%s is ready for querying.\n", index_name);
97 } else {
98 printf("Error occurred or index not found.\n");
99 }
100
101 // Cleanup
102 mongoc_collection_destroy(collection);
103 mongoc_client_destroy(client);
104 mongoc_cleanup();
105
106 return 0;
107}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

5

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

6
mkdir build && cd build
7
cmake ../
8
cmake --build .
9
./atlas-vector-search-quick-start
1New search index named vector_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3vector_index is ready for querying.
1

For detailed installation instructions, refer to the MongoDB C++ Driver documentation.

2
mkdir query-quick-start
3
cd query-quick-start
touch CMakeLists.txt

Copy and paste the following lines into the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.30)
project(query_quick_start)
set(CMAKE_CXX_STANDARD 17)
# You must use mongocxx driver version 3.11.0 or later to
# create a vector index.
find_package(mongocxx REQUIRED)
find_package(bsoncxx REQUIRED)
add_executable(query_quick_start
vector_index.cpp
)
target_link_libraries(query_quick_start PRIVATE mongo::mongocxx_shared)
target_link_libraries(query_quick_start PRIVATE mongo::bsoncxx_shared)
4

Create a file named vector_index.cpp. Copy and paste the following code into the file.

vector_index.cpp
1#include <bsoncxx/builder/basic/document.hpp>
2#include <iostream>
3#include <mongocxx/client.hpp>
4#include <mongocxx/instance.hpp>
5#include <mongocxx/search_index_view.hpp>
6#include <mongocxx/uri.hpp>
7#include <thread>
8
9using bsoncxx::builder::basic::kvp;
10using bsoncxx::builder::basic::make_array;
11using bsoncxx::builder::basic::make_document;
12
13int main() {
14 try {
15 mongocxx::instance inst{};
16
17 // Replace the placeholder with your connection string
18 const auto uri = mongocxx::uri{"<connection-string>"};
19
20 // Connect to your cluster
21 mongocxx::client conn{uri};
22 auto db = conn["sample_mflix"];
23 auto collection = db["embedded_movies"];
24
25 auto siv = collection.search_indexes();
26 std::string name = "vector_index";
27 auto type = "vectorSearch";
28 auto definition = make_document(
29 kvp("fields",
30 make_array(make_document(
31 kvp("type", "vector"), kvp("path", "plot_embedding_voyage_3_large"),
32 kvp("numDimensions", 2048), kvp("similarity", "dotProduct"),
33 kvp("quantization", "scalar")))));
34 auto model =
35 mongocxx::search_index_model(name, definition.view()).type(type);
36 siv.create_one(model);
37 std::cout << "New search index named " << name << " is building."
38 << std::endl;
39
40 // Polling for index status
41 std::cout << "Polling to check if the index is ready. This may take up to "
42 "a minute."
43 << std::endl;
44 bool queryable = false;
45 while (!queryable) {
46 auto indexes = siv.list();
47 for (const auto& index : indexes) {
48 if (index["name"].get_value() == name) {
49 queryable = index["queryable"].get_bool();
50 }
51 }
52 if (!queryable) {
53 std::this_thread::sleep_for(std::chrono::seconds(5));
54 }
55 }
56 std::cout << name << " is ready for querying." << std::endl;
57 } catch (const std::exception& e) {
58 std::cout << "Exception: " << e.what() << std::endl;
59 }
60 return 0;
61}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

5

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

6
mkdir build && cd build
7
cmake ../
8
cmake --build .
9
./query_quick_start
1New search index named vector_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3vector_index is ready for querying.
1

In your terminal, run the following commands:

mkdir query-quick-start
cd query-quick-start
dotnet new console
2
dotnet add package MongoDB.Driver

For more detailed installation instructions, see the MongoDB .NET/C# Driver documentation.

3

Create a file named IndexService.cs. Copy and paste the following code into the file.

IndexService.cs
1namespace query_quick_start;
2
3using MongoDB.Bson;
4using MongoDB.Driver;
5using System;
6using System.Threading;
7
8public class IndexService
9{
10 // Replace the placeholder with your connection string
11 private const string MongoConnectionString = "<connectionString>";
12 public void CreateVectorIndex()
13 {
14 try
15 {
16 // Connect to your cluster
17 var client = new MongoClient(MongoConnectionString);
18 var database = client.GetDatabase("sample_mflix");
19 var collection = database.GetCollection<BsonDocument>("embedded_movies");
20
21 var searchIndexView = collection.SearchIndexes;
22 var name = "vector_index";
23
24 var model = new CreateVectorSearchIndexModel<Movie>(
25 m => m.PlotEmbedding,
26 name,
27 VectorSimilarity.DotProduct,
28 2048)
29 {
30 Quantization = VectorQuantization.Scalar
31 };
32
33 searchIndexView.CreateOne(model);
34 Console.WriteLine($"New search index named {name} is building.");
35
36 // Polling for index status
37 Console.WriteLine("Polling to check if the index is ready. This may take up to a minute.");
38 bool queryable = false;
39 while (!queryable)
40 {
41 var indexes = searchIndexView.List();
42 foreach (var index in indexes.ToEnumerable())
43 {
44 if (index["name"] == name)
45 {
46 queryable = index["queryable"].AsBoolean;
47 }
48 }
49 if (!queryable)
50 {
51 Thread.Sleep(5000);
52 }
53 }
54 Console.WriteLine($"{name} is ready for querying.");
55 }
56 catch (Exception e)
57 {
58 Console.WriteLine($"Exception: {e.Message}");
59 }
60 }
61}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
Program.cs
using query_quick_start;
var indexService = new IndexService();
indexService.CreateVectorIndex();
6
dotnet run query-quick-start.csproj
1New search index named vector_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3vector_index is ready for querying.
1

Select one of the following tabs, depending on your package manager:

If you are using Maven, add the following dependencies to the dependencies array in your project's pom.xml file:

pom.xml
<dependencies>
<!-- MongoDB Java Sync Driver v5.2.0 or later -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>[5.2.0,)</version>
</dependency>
</dependencies>
2

For more detailed installation instructions and version compatibility, see the MongoDB Java Driver documentation.

3
VectorIndex.java
1import com.mongodb.client.MongoClient;
2import com.mongodb.client.MongoClients;
3import com.mongodb.client.MongoCollection;
4import com.mongodb.client.MongoDatabase;
5import com.mongodb.client.model.SearchIndexModel;
6import com.mongodb.client.model.SearchIndexType;
7import org.bson.Document;
8import org.bson.conversions.Bson;
9
10import java.util.Collections;
11import java.util.List;
12
13public class VectorIndex {
14
15 public static void main(String[] args) {
16
17 // Replace the placeholder with your connection string
18 String uri = "<connectionString>";
19
20 // Connect to your cluster
21 try (MongoClient mongoClient = MongoClients.create(uri)) {
22
23 // Set the namespace
24 MongoDatabase database = mongoClient.getDatabase("sample_mflix");
25 MongoCollection<Document> collection = database.getCollection("embedded_movies");
26
27 // Define the index details
28 String indexName = "vector_index";
29 Bson definition = new Document(
30 "fields",
31 Collections.singletonList(
32 new Document("type", "vector")
33 .append("path", "plot_embedding_voyage_3_large")
34 .append("numDimensions", 2048)
35 .append("similarity", "dotProduct")
36 .append("quantization", "scalar")));
37
38 // Define the index model
39 SearchIndexModel indexModel = new SearchIndexModel(
40 indexName,
41 definition,
42 SearchIndexType.vectorSearch());
43
44 // Create the index using the defined model
45 List<String> result = collection.createSearchIndexes(Collections.singletonList(indexModel));
46 System.out.println("Successfully created vector index named: " + result.get(0));
47 System.out.println("It may take up to a minute for the index to leave the BUILDING status and become queryable.");
48
49 // Wait for index to build and become queryable
50 System.out.println("Polling to confirm the index has left the BUILDING status.");
51 // No special handling in case of a timeout. Custom handling can be implemented.
52 waitForIndex(collection, indexName);
53 }
54 }
55
56 /**
57 * Polls the collection to check whether the specified index is ready to query.
58 */
59 public static <T> boolean waitForIndex(final MongoCollection<T> collection, final String indexName) {
60 long startTime = System.nanoTime();
61 long timeoutNanos = TimeUnit.SECONDS.toNanos(60);
62 while (System.nanoTime() - startTime < timeoutNanos) {
63 Document indexRecord = StreamSupport.stream(collection.listSearchIndexes().spliterator(), false)
64 .filter(index -> indexName.equals(index.getString("name")))
65 .findAny().orElse(null);
66 if (indexRecord != null) {
67 if ("FAILED".equals(indexRecord.getString("status"))) {
68 throw new RuntimeException("Search index has FAILED status.");
69 }
70 if (indexRecord.getBoolean("queryable")) {
71 System.out.println(indexName + " index is ready to query");
72 return true;
73 }
74 }
75 try {
76 Thread.sleep(100); // busy-wait, avoid in production
77 } catch (InterruptedException e) {
78 Thread.currentThread().interrupt();
79 throw new RuntimeException(e);
80 }
81 }
82 return false;
83 }
84}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
javac VectorIndex.java
java VectorIndex
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

For more detailed installation instructions and version compatibility, see the MongoDB Kotlin Coroutine Driver documentation.

2

Create a file named VectorIndex.kt. Copy and paste the following code into the file.

VectorIndex.kt
1import com.mongodb.MongoException
2import com.mongodb.client.model.SearchIndexModel
3import com.mongodb.client.model.SearchIndexType
4import com.mongodb.kotlin.client.coroutine.MongoClient
5import kotlinx.coroutines.delay
6import kotlinx.coroutines.flow.toList
7import org.bson.Document
8import kotlinx.coroutines.runBlocking
9
10fun main() {
11 // Replace the placeholder with your MongoDB deployment's connection string
12 val uri = "<connection-string>"
13 val mongoClient = MongoClient.create(uri)
14 val database = mongoClient.getDatabase("sample_mflix")
15 val collection = database.getCollection<Document>("embedded_movies")
16 val indexName = "vector_index"
17 val searchIndexModel = SearchIndexModel(
18 indexName,
19 Document(
20 "fields",
21 listOf(
22 Document("type", "vector")
23 .append("path", "plot_embedding_voyage_3_large")
24 .append("numDimensions", 2048)
25 .append("similarity", "dotProduct")
26 .append("quantization", "scalar")
27 )
28 ),
29 SearchIndexType.vectorSearch()
30 )
31
32 runBlocking {
33 try {
34 collection.createSearchIndexes(listOf(searchIndexModel))
35 .collect { result ->
36 println("New search index named $result is building.")
37 }
38
39 // Polling to check if the index is queryable
40 println("Polling to check if the index is ready. This may take up to a minute.")
41 var isQueryable = false
42 while (!isQueryable) {
43 delay(5000L) // Poll every 5 seconds
44
45 val indexes = collection.listSearchIndexes().toList()
46 isQueryable = indexes.any { index ->
47 index.getString("name") == indexName && index.getBoolean("queryable")
48 }
49 if (isQueryable) {
50 println("$indexName is ready for querying.")
51 }
52 }
53 } catch (me: MongoException) {
54 System.err.println("An error occurred: $me")
55 }
56 }
57 mongoClient.close()
58}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4

The output should resemble the following:

New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1
npm install mongodb

Tip

The examples on this page assume your project manages modules as CommonJS modules. If you're using ES modules, instead, you must modify the import syntax.

2

Create a file named vector-index.js. Copy and paste the following code into the file.

vector-index.js
1const { MongoClient } = require("mongodb");
2
3// connect to your deployment
4const uri = "<connectionString>";
5
6const client = new MongoClient(uri);
7
8async function run() {
9 try {
10 const database = client.db("sample_mflix");
11 const collection = database.collection("embedded_movies");
12
13 // define your MongoDB Vector Search index
14 const index = {
15 name: "vector_index",
16 type: "vectorSearch",
17 definition: {
18 "fields": [
19 {
20 "type": "vector",
21 "numDimensions": 2048,
22 "path": "plot_embedding_voyage_3_large",
23 "similarity": "dotProduct",
24 "quantization": "scalar"
25 }
26 ]
27 }
28 }
29
30 // run the helper method
31 const result = await collection.createSearchIndex(index);
32 console.log(`New search index named ${result} is building.`);
33
34 // wait for the index to be ready to query
35 console.log("Polling to check if the index is ready. This may take up to a minute.")
36 let isQueryable = false;
37 while (!isQueryable) {
38 const cursor = collection.listSearchIndexes();
39 for await (const index of cursor) {
40 if (index.name === result) {
41 if (index.queryable) {
42 console.log(`${result} is ready for querying.`);
43 isQueryable = true;
44 } else {
45 await new Promise(resolve => setTimeout(resolve, 5000));
46 }
47 }
48 }
49 }
50 } finally {
51 await client.close();
52 }
53}
54run().catch(console.dir);

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
node vector-index.js
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

For detailed installation instructions, see the MongoDB PHP Library documentation.

2

Create a file named vector-index.php. Copy and paste the following code into the file.

vector-index.php
1<?php
2
3require 'vendor/autoload.php';
4
5// Replace the placeholder with your connection string
6$uri = "<connectionString>";
7$client = new MongoDB\Client($uri);
8$collection = $client->sample_mflix->embedded_movies;
9$indexName = "vector_index";
10try {
11 $result = $collection->createSearchIndexes(
12 [[
13 'name' => $indexName,
14 'type' => 'vectorSearch',
15 'definition' => [
16 'fields' => [[
17 'type' => 'vector',
18 'path' => 'plot_embedding_voyage_3_large',
19 'numDimensions' => 2048,
20 'similarity' => 'dotProduct',
21 'quantization' => 'scalar'
22 ]]
23 ],
24 ]]
25 );
26 echo "New search index named $result[0] is building." .PHP_EOL;
27
28 // Polling for the index to become queryable
29 echo "Polling to check if the index is ready. This may take up to a minute." .PHP_EOL;
30 $isIndexQueryable = false;
31 while (!$isIndexQueryable) {
32 // List the search indexes
33 $searchIndexes = $collection->listSearchIndexes();
34 // Check if the index is present and queryable
35 foreach ($searchIndexes as $index) {
36 if ($index->name === $indexName) {
37 $isIndexQueryable = $index->queryable;
38 }
39 }
40 if (!$isIndexQueryable) {
41 sleep(5); // Wait for 5 seconds before polling again
42 }
43 }
44 echo "$indexName is ready for querying." .PHP_EOL;
45}
46catch (MongoDB\Driver\Exception\Exception $e) {
47 print 'Error creating the index: ' .$e->getMessage() .PHP_EOL;
48}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
php vector-index.php
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1
pip install pymongo

For more detailed installation instructions, see the MongoDB Python Driver documentation.

2

Create a file named vector-index.py. Copy and paste the following code into the file.

vector-index.py
1from pymongo.mongo_client import MongoClient
2from pymongo.operations import SearchIndexModel
3import time
4
5# Connect to your deployment
6uri = "<connectionString>"
7client = MongoClient(uri)
8
9# Access your database and collection
10database = client["sample_mflix"]
11collection = database["embedded_movies"]
12
13# Create your index model, then create the search index
14search_index_model = SearchIndexModel(
15 definition={
16 "fields": [
17 {
18 "type": "vector",
19 "path": "plot_embedding_voyage_3_large",
20 "numDimensions": 2048,
21 "similarity": "dotProduct",
22 "quantization": "scalar"
23 }
24 ]
25 },
26 name="vector_index",
27 type="vectorSearch"
28)
29
30result = collection.create_search_index(model=search_index_model)
31print("New search index named " + result + " is building.")
32
33# Wait for initial sync to complete
34print("Polling to check if the index is ready. This may take up to a minute.")
35predicate=None
36if predicate is None:
37 predicate = lambda index: index.get("queryable") is True
38
39while True:
40 indices = list(collection.list_search_indexes(result))
41 if len(indices) and predicate(indices[0]):
42 break
43 time.sleep(5)
44print(result + " is ready for querying.")
45
46client.close()

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
python vector-index.py
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1
  1. If you don't already have a Gemfile for your project, run the following command from your project directory to generate one:

    bundle init
  2. Add the mongo gem to your Gemfile:

    Gemfile
    gem "mongo"
  3. Run the following command to install the dependency:

    bundle install

This installs the latest version of the Ruby driver. For alternate installation instructions and version compatibility, see the MongoDB Ruby Driver documentation.

2
3
vector_index.rb
1require 'mongo'
2require 'json'
3
4uri = "<connection-string>"
5
6begin
7 # Connect to the MongoDB client
8 client = Mongo::Client.new(uri, database: 'sample_mflix')
9
10 # Set the namespace
11 db = client.database
12 collection = db[:embedded_movies]
13
14 # Define the Vector Search index definition
15 index_definition = {
16 fields: [
17 {
18 type: "vector",
19 path: "plot_embedding_voyage_3_large",
20 numDimensions: 2048,
21 similarity: "dotProduct"
22 }
23 ]
24 }
25
26 # Create the index using `create_one`
27 index_name = collection.search_indexes.create_one(
28 index_definition,
29 name: 'vector_index',
30 type: 'vectorSearch'
31 )
32
33 puts "Vector search index created successfully: #{index_name}"
34
35rescue Mongo::Error::NoServerAvailable => e
36 # Handle MongoDB server connection issues
37 puts "Failed to connect to MongoDB: #{e.message}"
38
39rescue Mongo::Error::OperationFailure => e
40 # Handle MongoDB operation failure issues
41 puts "Failed to perform operation: #{e.message}"
42
43rescue Mongo::Error => e
44 # Handle general MongoDB-related errors
45 puts "A MongoDB error occurred: #{e.message}"
46
47rescue StandardError => e
48 # Handle any other kinds of errors
49 puts "A general error occurred: #{e.message}"
50
51ensure
52 # Ensure the client is closed
53 client&.close
54 puts "MongoDB client closed."
55end
4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
bundle exec ruby vector_index.rb
1

For more detailed installation instructions, see the MongoDB Rust Driver documentation.

2

In the /src directory of your project, create a file named vector_index.rs. Copy and paste the following code into the file.

vector_index.rs
1use std::time::Duration;
2use futures::TryStreamExt;
3use mongodb::{bson::{doc, Document}, Client, Collection, SearchIndexModel};
4use mongodb::SearchIndexType::VectorSearch;
5use tokio::time::sleep;
6
7pub(crate) async fn vector_index() {
8 // Replace the placeholder with your connection string
9 let uri = "<connection_string>";
10
11 // Create a new client and connect to the server
12 let client = Client::with_uri_str(uri).await.unwrap();
13
14 // Get a handle on the movies collection
15 let database = client.database("sample_mflix");
16 let my_coll: Collection<Document> = database.collection("embedded_movies");
17
18 let index_name = "vector_index";
19 let search_index_def = SearchIndexModel::builder()
20 .definition(doc! {
21 "fields": vec! {doc! {
22 "type": "vector",
23 "path": "plot_embedding_voyage_3_large",
24 "numDimensions": 2048,
25 "similarity": "dotProduct",
26 "quantization": "scalar"
27 }}
28 })
29 .name(index_name.to_string())
30 .index_type(VectorSearch)
31 .build();
32
33 let models = vec![search_index_def];
34 match my_coll.create_search_indexes(models).await {
35 Err(e) => {
36 eprintln!("There was an error creating the search index: {}", e);
37 std::process::exit(1)
38 }
39 Ok(names) => {
40 println!("New search index named {} is building.", names[0]);
41 }
42 }
43
44 // Polling for the index to become queryable
45 println!("Polling to check if the index is ready. This may take up to a minute.");
46 let mut is_index_queryable = false;
47 while !is_index_queryable {
48 // List the search indexes
49 let mut search_indexes = my_coll.list_search_indexes().await.unwrap();
50 // Check if the index is present and queryable
51 while let Some(index) = search_indexes.try_next().await.unwrap() {
52 if index.get_str("name") == Ok(index_name) {
53 is_index_queryable = index.get_bool("queryable").unwrap_or(false);
54 }
55 }
56 if !is_index_queryable {
57 sleep(Duration::from_secs(5)).await; // Wait for 5 seconds before polling again
58 }
59 }
60 println!("{} is ready for querying.", index_name);
61}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
mod vector_index;
#[tokio::main]
async fn main() {
vector_index::vector_index().await;
}
5
cargo run
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1

For installation instructions based on your environment and the version of Scala you are using, refer to the MongoDB Scala Driver documentation.

2

For this quick start, we create a project named quick-start, by using sbt.

sbt new scala/hello-world.g8

When prompted, name the application quick-start.

3

Copy and paste the following code into the file.

VectorIndex.scala
1import org.mongodb.scala._
2import org.mongodb.scala.model._
3import com.mongodb.client.model.SearchIndexType
4
5class VectorIndex {
6 def createIndex(): Unit = {
7 val collection =
8 MongoClient("<connectionString>")
9 .getDatabase("sample_mflix")
10 .getCollection("embedded_movies")
11 val indexName = "vector_index"
12 val indexNameAsOption = Option(indexName)
13 val indexDefinition = Document(
14 "fields" -> List(
15 Document(
16 "type" -> "vector",
17 "path" -> "plot_embedding_voyage_3_large",
18 "numDimensions" -> 2048,
19 "similarity" -> "dotProduct",
20 "quantization" -> "scalar"
21 )
22 )
23 )
24 val indexType = Option(SearchIndexType.vectorSearch())
25 val indexModel: SearchIndexModel = SearchIndexModel(
26 indexNameAsOption, indexDefinition, indexType
27 )
28 collection.createSearchIndexes(List(indexModel)).foreach { doc => println(s"New search index named $doc is building.") }
29 Thread.sleep(2000)
30 println("Polling to check if the index is ready. This may take up to a minute.")
31 var indexReady = false
32 while (!indexReady) {
33 val searchIndexes = collection.listSearchIndexes()
34 searchIndexes.foreach { current =>
35 val document = current.toBsonDocument()
36 val name = document.get("name").asString().getValue
37 val queryable = document.get("queryable").asBoolean().getValue
38 if (name == indexName && queryable) {
39 indexReady = true
40 }
41 }
42 if (!indexReady) {
43 Thread.sleep(5000)
44 }
45 }
46 println(s"$indexName is ready for querying.")
47 }
48}

This index definition:

This code also includes a polling mechanism to check if the index is ready to use.

4

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

5
object Main extends App {
private val indexInstance = new VectorIndex
indexInstance.createIndex()
}
6

There are many tools and environments in which Scala runs. In this example, we run the new Scala project by starting the sbt server with the sbt command, then typing ~run.

sbt:quick-start> ~run
New search index named vector_index is building.
Polling to check if the index is ready. This may take up to a minute.
vector_index is ready for querying.
1
2

Search Type

Select the Vector Search index type.

How do you want to set up your vector data?

Select one of the following:

  • Automated Embedding if you want MongoDB to generate and manage vector embeddings for your text fields.

  • Bring your own embeddings if you have already generated vector embeddings for your data.

Choose Automated Embedding.

Index Name and Data Source

Specify the following information:

  • Index Name: autoembed_index

  • Database and Collection:

    • sample_mflix

    • movies

Configuration Method

For a guided experience, select Visual Editor.

To edit the raw index definition, select JSON Editor.

3

This index definition:

  • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

  • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

Select the following from the dropdowns:

Field
Value

Path

fullplot

Embedding Model

voyage-4

For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

4
5

The index should take about one minute to build. When your vector index is finished building, the Status column reads Active.

1

To learn more, see Connect to a Cluster via Compass.

2

On the Database screen, expand the name of the database, sample_mflix, then click the name of the collection, movies.

3
  1. Click the Indexes tab, then select Search Indexes.

  2. Click Create Search Index to open the index creation dialog box.

  3. Enter autoembed_index as the name of the index.

  4. Define the MongoDB Vector Search index.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vector_index
    1{
    2 "fields": [
    3 {
    4 "type": "autoEmbed",
    5 "modality": "text",
    6 "path": "fullplot",
    7 "model": "voyage-4"
    8 }
    9 ]
    10}

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  5. Click Create Search Index.

1

To learn more, see Connect to a Cluster via mongosh.

2

Example

use sample_mflix
switched to db sample_mflix
3

To create the index named autoembed_index, run the following db.collection.createSearchIndex() method:

autoembed_index
1db.movies.createSearchIndex(
2 "autoembed_index",
3 "vectorSearch",
4 {
5 "fields": [
6 {
7 "type": "autoEmbed",
8 "modality": "text",
9 "path": "fullplot",
10 "model": "voyage-4"
11 }
12 ]
13 }
14);

This index definition:

  • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

  • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

Note

Wait for the index build to complete. This might take some time.

Run the following command in mongosh to check the index status:

db.movies.getSearchIndexes().forEach(printjson)
1

To define a MongoDB Vector Search index:

  1. In your shell, run the following commands to create a directory called VectorSearch and initialize a .NET Framework project for a new console application:

    mkdir VectorSearch
    cd VectorSearch
    dotnet new console
  2. Run the following command to install the current version of the .NET/C# driver as a dependency of your project:

    dotnet add package MongoDB.Driver
  3. Copy and paste the following code into the Program.cs file in your application:

    Program.cs
    1using MongoDB.Bson;
    2using MongoDB.Driver;
    3
    4var connectionString = "<connection string>";
    5var client = new MongoClient(connectionString);
    6var database = client.GetDatabase("sample_mflix");
    7var collection = database.GetCollection<BsonDocument>("movies");
    8
    9var searchIndexView = collection.SearchIndexes;
    10var name = "autembed_index";
    11
    12var definition = new BsonDocument
    13{
    14 { "fields", new BsonArray
    15 {
    16 new BsonDocument
    17 {
    18 { "type", "autoEmbed" },
    19 { "modality", "text" },
    20 { "path", "fullplot" },
    21 { "model", "voyage-4" }
    22 }
    23 }
    24 }
    25};
    26
    27var model = new CreateSearchIndexModel(name, SearchIndexType.VectorSearch, definition);
    28searchIndexView.CreateOne(model);
    29Console.WriteLine($"New search index named {name} is building.");
    30
    31Console.WriteLine("Polling to check if the index is ready.");
    32bool queryable = false;
    33while (!queryable)
    34{
    35 var indexes = searchIndexView.List();
    36 foreach (var index in indexes.ToEnumerable())
    37 {
    38 if (index["name"] == name)
    39 {
    40 queryable = index["queryable"].AsBoolean;
    41 }
    42 }
    43 if (!queryable)
    44 {
    45 Thread.Sleep(5000);
    46 }
    47}
    48Console.WriteLine($"{name} is ready for querying.");

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

To create the index, run the following command:

dotnet run
1

To define a MongoDB Vector Search auto-embedding index, complete the following steps:

  1. Run the following command in your terminal to create a .go file in a Go project directory:

    touch create-index.go
  2. Copy and paste the following index definition into the file:

    create-index.go
    1// create-index.go
    2//
    3// This example creates an auto-embedding MongoDB Vector Search index
    4// on the "fullplot" field of the sample_mflix.movies collection.
    5// The index uses the "voyage-4" model.
    6// start-create-index
    7package main
    8
    9import (
    10 "context"
    11 "fmt"
    12 "log"
    13 "time"
    14
    15 "go.mongodb.org/mongo-driver/v2/bson"
    16 "go.mongodb.org/mongo-driver/v2/mongo"
    17 "go.mongodb.org/mongo-driver/v2/mongo/options"
    18)
    19
    20const (
    21 indexName = "autoembed_index"
    22)
    23
    24// autoEmbedField represents the auto-embedding index field definition.
    25type autoEmbedField struct {
    26 Type string `bson:"type"` // "autoEmbed"
    27 Modality string `bson:"modality"` // "text"
    28 Path string `bson:"path"` // e.g. "fullplot"
    29 Model string `bson:"model"` // e.g. "voyage-4"
    30}
    31
    32// autoEmbedIndexDefinition is the top-level index definition.
    33type autoEmbedIndexDefinition struct {
    34 Fields []any `bson:"fields"`
    35}
    36
    37func main() {
    38 // Replace with your MongoDB connection string.
    39 uri := "<connection-string>"
    40
    41 // Create a context with a timeout for index creation and polling.
    42 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
    43 defer cancel()
    44
    45 // Connect to your deployment.
    46 client, err := mongo.Connect(options.Client().ApplyURI(uri))
    47 if err != nil {
    48 log.Fatalf("Failed to connect to MongoDB: %v", err)
    49 }
    50 defer func() {
    51 if err := client.Disconnect(context.Background()); err != nil {
    52 log.Printf("Error disconnecting client: %v", err)
    53 }
    54 }()
    55
    56 // Access your database and collection.
    57 db := client.Database("sample_mflix")
    58 coll := db.Collection("movies")
    59
    60 // 1. Create the auto-embedding vectorSearch index.
    61 if err := createAutoEmbeddingIndex(ctx, coll); err != nil {
    62 log.Fatalf("Failed to create auto-embedding index: %v", err)
    63 }
    64 fmt.Println("New search index named", indexName, "is building.")
    65
    66 // 2. Wait until the index is queryable (initial sync complete).
    67 fmt.Println("Polling to check if the index is ready. This may take up to a minute.")
    68 if err := waitForIndexQueryable(ctx, coll, indexName); err != nil {
    69 log.Fatalf("Error while waiting for index to become queryable: %v", err)
    70 }
    71 fmt.Println(indexName, "is ready for querying.")
    72}
    73
    74func createAutoEmbeddingIndex(ctx context.Context, coll *mongo.Collection) error {
    75 // Define the index fields.
    76 definition := autoEmbedIndexDefinition{
    77 Fields: []any{
    78 autoEmbedField{
    79 Type: "autoEmbed",
    80 Modality: "text",
    81 Path: "fullplot",
    82 Model: "voyage-4",
    83 },
    84 },
    85 }
    86
    87 // Set index name and type "vectorSearch".
    88 opts := options.SearchIndexes().
    89 SetName(indexName).
    90 SetType("vectorSearch")
    91
    92 model := mongo.SearchIndexModel{
    93 Definition: definition,
    94 Options: opts,
    95 }
    96
    97 _, err := coll.SearchIndexes().CreateOne(ctx, model)
    98 return err
    99}
    100
    101func waitForIndexQueryable(ctx context.Context, coll *mongo.Collection, name string) error {
    102 for {
    103 // List just this index by name.
    104 opts := options.SearchIndexes().SetName(name)
    105 cursor, err := coll.SearchIndexes().List(ctx, opts)
    106 if err != nil {
    107 return fmt.Errorf("list search indexes: %w", err)
    108 }
    109
    110 var results []bson.M
    111 if err := cursor.All(ctx, &results); err != nil {
    112 return fmt.Errorf("decode search index list: %w", err)
    113 }
    114
    115 if len(results) > 0 {
    116 if q, ok := results[0]["queryable"].(bool); ok && q {
    117 return nil
    118 }
    119 }
    120
    121 select {
    122 case <-ctx.Done():
    123 return ctx.Err()
    124 case <-time.After(5 * time.Second):
    125 // Continue polling.
    126 }
    127 }
    128}
    129
    130// end-create-index

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connection-string> placeholder in the index definition with your deployment's connection string and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following command:

go run create-index.go
1

To define a MongoDB Vector Search index:

  1. Create a .java file.

    touch vectorIndex.java
  2. Copy and paste the following index definition in to the file.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vectorIndex.java
    1import com.mongodb.client.MongoClient;
    2import com.mongodb.client.MongoClients;
    3import com.mongodb.client.MongoCollection;
    4import com.mongodb.client.MongoDatabase;
    5import com.mongodb.client.model.SearchIndexModel;
    6import com.mongodb.client.model.SearchIndexType;
    7import org.bson.Document;
    8
    9import java.util.Arrays;
    10import java.util.Collections;
    11
    12public class CreateIndex {
    13 public static void main(String[] args) throws InterruptedException {
    14 // connect to your deployment
    15 String uri = "<connectionString>";
    16
    17 try (MongoClient client = MongoClients.create(uri)) {
    18 MongoDatabase database = client.getDatabase("sample_mflix");
    19 MongoCollection<Document> collection = database.getCollection("movies");
    20
    21 // define your MongoDB Vector Search index
    22 SearchIndexModel indexModel = new SearchIndexModel(
    23 "autoembed_index",
    24 new Document("fields",
    25 Arrays.asList(
    26 new Document("type", "autoEmbed")
    27 .append("modality", "text")
    28 .append("path", "fullplot")
    29 .append("model", "voyage-4")
    30 )
    31 ),
    32 SearchIndexType.vectorSearch()
    33 );
    34
    35 // run the helper method
    36 String result = collection.createSearchIndexes(Collections.singletonList(indexModel)).get(0);
    37 System.out.println("New search index named " + result + " is building.");
    38
    39 System.out.println("Polling to check if the index is ready. This may take up to a minute.");
    40 boolean isQueryable = false;
    41 while (!isQueryable) {
    42 for (Document index : collection.listSearchIndexes()) {
    43 if (result.equals(index.getString("name"))) {
    44 String status = index.getString("status");
    45 if ("READY".equals(status) || status == null) {
    46 System.out.println(result + " is ready for querying.");
    47 isQueryable = true;
    48 }
    49 break;
    50 }
    51 }
    52
    53 // wait for the index to be ready to query
    54 if (!isQueryable) {
    55 Thread.sleep(5000);
    56 }
    57 }
    58 }
    59 }
    60}

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connectionString> in the index definition and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following commands:

javac vectorIndex.java
java vectorIndex
1

To define a MongoDB Vector Search index:

  1. Create a .js file.

    touch vector_index.js
  2. Copy and paste the following index definition in to the file.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vector_index.js
    1const { MongoClient } = require("mongodb");
    2const { setTimeout } = require("timers/promises");
    3
    4const uri = "<CONNECTION-STRING>";
    5const client = new MongoClient(uri);
    6
    7async function run() {
    8 try {
    9 const database = client.db("sample_mflix");
    10 const collection = database.collection("movies");
    11
    12 // define your MongoDB Vector Search index
    13 const index = {
    14 name: "autoembed_index",
    15 type: "vectorSearch",
    16 definition: {
    17 fields: [
    18 {
    19 type: "autoEmbed",
    20 modality: "text",
    21 path: "fullplot",
    22 model: "voyage-4"
    23 }
    24 ]
    25 }
    26 };
    27
    28 // run the helper method
    29 const result = await collection.createSearchIndex(index);
    30 console.log(`New search index named ${result} is building.`);
    31
    32 console.log("Polling to check if the index is ready. This may take up to a minute.");
    33 let isQueryable = false;
    34 while (!isQueryable) {
    35 const [indexData] = await collection.listSearchIndexes(index.name).toArray();
    36 if (indexData) {
    37 isQueryable = indexData.queryable;
    38 if (!isQueryable) {
    39 await setTimeout(5000);
    40 }
    41 } else {
    42 console.log(`Index ${index.name} not found.`);
    43 await setTimeout(5000);
    44 }
    45 }
    46 console.log(`${result} is ready for querying.`);
    47 } finally {
    48 await client.close();
    49 }
    50}
    51
    52run().catch(console.dir);

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connectionString> in the index definition and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following command:

node vector_index.js
1

To define a MongoDB Vector Search index:

  1. Create a .py file.

    touch vector_index.py
  2. Copy and paste the following index definition in to the file.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vector_index.py
    1import time
    2from pymongo import MongoClient
    3from pymongo.operations import SearchIndexModel
    4
    5client = MongoClient("<CONNECTION-STRING>")
    6collection = client["sample_mflix"]["movies"]
    7
    8# define your MongoDB Vector Search index
    9search_index_model = SearchIndexModel(
    10 definition={
    11 "fields": [
    12 {
    13 "type": "autoEmbed",
    14 "modality": "text",
    15 "path": "fullplot",
    16 "model": "voyage-4"
    17 }
    18 ]
    19 },
    20 name="autoembed_index",
    21 type="vectorSearch",
    22)
    23
    24# run the helper method
    25result = collection.create_search_index(model=search_index_model)
    26print(f"New search index named {result} is building.")
    27
    28print("Polling to check if the index is ready. This may take up to a minute.")
    29while True:
    30 indices = list(collection.list_search_indexes(result))
    31 if len(indices) and indices[0].get("queryable"):
    32 break
    33 time.sleep(5)
    34print(f"{result} is ready for querying.")

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connectionString> in the index definition and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following command:

python vector_index.py
1

For detailed installation instructions, refer to the MongoDB C++ Driver documentation.

2
mkdir query-quick-start
3
cd query-quick-start
touch CMakeLists.txt

Copy and paste the following lines into the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.30)
project(query_quick_start)
set(CMAKE_CXX_STANDARD 17)
# You must use mongocxx driver version 3.11.0 or later to
# create a vector index.
find_package(mongocxx REQUIRED)
find_package(bsoncxx REQUIRED)
add_executable(query_quick_start
vector_index.cpp
)
target_link_libraries(query_quick_start PRIVATE mongo::mongocxx_shared)
target_link_libraries(query_quick_start PRIVATE mongo::bsoncxx_shared)
4

Create a file named vector_index.cpp. Copy and paste the following code into the file.

vector_index.cpp
1#include <bsoncxx/builder/basic/document.hpp>
2#include <iostream>
3#include <mongocxx/client.hpp>
4#include <mongocxx/instance.hpp>
5#include <mongocxx/search_index_view.hpp>
6#include <mongocxx/uri.hpp>
7#include <thread>
8
9using bsoncxx::builder::basic::kvp;
10using bsoncxx::builder::basic::make_array;
11using bsoncxx::builder::basic::make_document;
12
13int main() {
14 try {
15 mongocxx::instance inst{};
16
17 // Replace the placeholder with your connection string
18 const auto uri = mongocxx::uri{"<connection-string>"};
19
20 // Connect to your cluster
21 mongocxx::client conn{uri};
22 auto db = conn["sample_mflix"];
23 auto collection = db["movies"];
24
25 auto siv = collection.search_indexes();
26 std::string name = "autoembed_index";
27 auto type = "vectorSearch";
28 auto definition = make_document(
29 kvp("fields",
30 make_array(make_document(
31 kvp("type", "autoEmbed"), kvp("modality", "text"),
32 kvp("path", "fullplot"), kvp("model", "voyage-4")))));
33 auto model =
34 mongocxx::search_index_model(name, definition.view()).type(type);
35 siv.create_one(model);
36 std::cout << "New search index named " << name << " is building."
37 << std::endl;
38
39 // Polling for index status
40 std::cout << "Polling to check if the index is ready. This may take up to "
41 "a minute."
42 << std::endl;
43 bool queryable = false;
44 while (!queryable) {
45 auto indexes = siv.list();
46 for (const auto& index : indexes) {
47 if (index["name"].get_value() == name) {
48 queryable = index["queryable"].get_bool();
49 }
50 }
51 if (!queryable) {
52 std::this_thread::sleep_for(std::chrono::seconds(5));
53 }
54 }
55 std::cout << name << " is ready for querying." << std::endl;
56 } catch (const std::exception& e) {
57 std::cout << "Exception: " << e.what() << std::endl;
58 }
59 return 0;
60}

For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

This code also includes a polling mechanism to check if the index is ready to use.

5

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

6
cmake -B build
7
cmake --build build
8
./query_quick_start
1New search index named autoembed_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3autoembed_index is ready for querying.

Note

Vector Search Index supports both asynchronous and synchronous runtimes. In the following steps, select your preferred runtime to learn how to create a Vector Search Index for it.

1

Select the tab for the runtime that you use and run the following commands to add the required dependencies:

cargo add mongodb
cargo add tokio --features full
cargo add futures

For further information about Rust with MongoDB, see the MongoDB Rust Driver documentation.

2

In the /src directory of your project, create a file named vector_index.rs, then copy and paste the following code into the file.

This index definition:

  • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

  • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

This code also includes a polling mechanism to check if the index is ready to use.

vector_index.rs
1use std::ops::Index;
2use std::time::Duration;
3use futures::{TryStreamExt};
4use mongodb::{bson::{Document, doc}, Client, Collection, SearchIndexModel};
5use mongodb::SearchIndexType::VectorSearch;
6use tokio::time::sleep;
7
8#[tokio::main]
9pub(crate) async fn vector_index() {
10 // Replace the placeholder with your connection string
11 let uri = "<connection-string>";
12
13 // Create a new client and connect to the server
14 let client = Client::with_uri_str(uri).await.unwrap();
15
16 // Get a handle on the movies collection
17 let database = client.database("sample_mflix");
18 let my_coll: Collection<Document> = database.collection("movies");
19
20 let index_name = "autoembed_index";
21 let search_index_def = SearchIndexModel::builder()
22 .definition(doc! {
23 "fields": vec! {doc! {
24 "type": "autoEmbed",
25 "modality": "text",
26 "path": "fullplot",
27 "model": "voyage-4"
28 }}
29 })
30 .name(index_name.to_string())
31 .index_type(VectorSearch)
32 .build();
33
34 let models = vec![search_index_def];
35 let result = my_coll.create_search_indexes(models).await;
36 if let Err(e) = result {
37 eprintln!("There was an error creating the search index: {}", e);
38 std::process::exit(1)
39 } else {
40 println!("New search index named {} is building.", result.unwrap().index(0));
41 }
42
43 // Polling for the index to become queryable
44 println!("Polling to check if the index is ready. This may take up to a minute.");
45 let mut is_index_queryable = false;
46 while !is_index_queryable {
47 // List the search indexes
48 let mut search_indexes = my_coll.list_search_indexes().await.unwrap();
49 // Check if the index is present and queryable
50 while let Some(index) = search_indexes.try_next().await.unwrap() {
51 let retrieved_name = index.get_str("name");
52 if retrieved_name.unwrap().to_string() == index_name {
53 is_index_queryable = index.get_bool("queryable").unwrap();
54 }
55 }
56 if !is_index_queryable {
57 sleep(Duration::from_secs(5)).await; // Wait for 5 seconds before polling again
58 }
59 }
60 println!("{} is ready for querying.", index_name);
61}
3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
mod vector_index;
fn main() {
vector_index::vector_index();
}
5
cargo run
New search index named autoembed_index is building.
Polling to check if the index is ready. This action may take up to a minute.
autoembed_index is ready for querying.
1

Example

use sample_mflix
switched to db sample_mflix
2

You can create an index of autoEmbed type to run natural language queries.

1db.movies.createSearchIndex(
2 "autoembed_index",
3 "vectorSearch",
4 {
5 "fields": [
6 {
7 "type": "autoEmbed",
8 "modality": "text",
9 "path": "fullplot",
10 "model": "voyage-4"
11 }
12 ]
13 }
14);

This index definition:

  • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

  • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

1

To define a MongoDB Vector Search index:

  1. In your shell, run the following commands to create a directory called VectorSearch and initialize a .NET Framework project for a new console application:

    mkdir VectorSearch
    cd VectorSearch
    dotnet new console
  2. Run the following command to install the current version of the .NET/C# driver as a dependency of your project:

    dotnet add package MongoDB.Driver
  3. Copy and paste the following code into the Program.cs file in your application:

    Program.cs
    1using MongoDB.Bson;
    2using MongoDB.Driver;
    3
    4var connectionString = "<connection string>";
    5var client = new MongoClient(connectionString);
    6var database = client.GetDatabase("sample_mflix");
    7var collection = database.GetCollection<BsonDocument>("movies");
    8
    9var searchIndexView = collection.SearchIndexes;
    10var name = "autembed_index";
    11
    12var definition = new BsonDocument
    13{
    14 { "fields", new BsonArray
    15 {
    16 new BsonDocument
    17 {
    18 { "type", "autoEmbed" },
    19 { "modality", "text" },
    20 { "path", "fullplot" },
    21 { "model", "voyage-4" }
    22 }
    23 }
    24 }
    25};
    26
    27var model = new CreateSearchIndexModel(name, SearchIndexType.VectorSearch, definition);
    28searchIndexView.CreateOne(model);
    29Console.WriteLine($"New search index named {name} is building.");
    30
    31Console.WriteLine("Polling to check if the index is ready.");
    32bool queryable = false;
    33while (!queryable)
    34{
    35 var indexes = searchIndexView.List();
    36 foreach (var index in indexes.ToEnumerable())
    37 {
    38 if (index["name"] == name)
    39 {
    40 queryable = index["queryable"].AsBoolean;
    41 }
    42 }
    43 if (!queryable)
    44 {
    45 Thread.Sleep(5000);
    46 }
    47}
    48Console.WriteLine($"{name} is ready for querying.");

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

To create the index, run the following command:

dotnet run
1

To define a MongoDB Vector Search auto-embedding index, complete the following steps:

  1. Run the following command in your terminal to create a .go file in a Go project directory:

    touch create-index.go
  2. Copy and paste the following index definition into the file:

    create-index.go
    1// create-index.go
    2//
    3// This example creates an auto-embedding MongoDB Vector Search index
    4// on the "fullplot" field of the sample_mflix.movies collection.
    5// The index uses the "voyage-4" model.
    6// start-create-index
    7package main
    8
    9import (
    10 "context"
    11 "fmt"
    12 "log"
    13 "time"
    14
    15 "go.mongodb.org/mongo-driver/v2/bson"
    16 "go.mongodb.org/mongo-driver/v2/mongo"
    17 "go.mongodb.org/mongo-driver/v2/mongo/options"
    18)
    19
    20const (
    21 indexName = "autoembed_index"
    22)
    23
    24// autoEmbedField represents the auto-embedding index field definition.
    25type autoEmbedField struct {
    26 Type string `bson:"type"` // "autoEmbed"
    27 Modality string `bson:"modality"` // "text"
    28 Path string `bson:"path"` // e.g. "fullplot"
    29 Model string `bson:"model"` // e.g. "voyage-4"
    30}
    31
    32// autoEmbedIndexDefinition is the top-level index definition.
    33type autoEmbedIndexDefinition struct {
    34 Fields []any `bson:"fields"`
    35}
    36
    37func main() {
    38 // Replace with your MongoDB connection string.
    39 uri := "<connection-string>"
    40
    41 // Create a context with a timeout for index creation and polling.
    42 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
    43 defer cancel()
    44
    45 // Connect to your deployment.
    46 client, err := mongo.Connect(options.Client().ApplyURI(uri))
    47 if err != nil {
    48 log.Fatalf("Failed to connect to MongoDB: %v", err)
    49 }
    50 defer func() {
    51 if err := client.Disconnect(context.Background()); err != nil {
    52 log.Printf("Error disconnecting client: %v", err)
    53 }
    54 }()
    55
    56 // Access your database and collection.
    57 db := client.Database("sample_mflix")
    58 coll := db.Collection("movies")
    59
    60 // 1. Create the auto-embedding vectorSearch index.
    61 if err := createAutoEmbeddingIndex(ctx, coll); err != nil {
    62 log.Fatalf("Failed to create auto-embedding index: %v", err)
    63 }
    64 fmt.Println("New search index named", indexName, "is building.")
    65
    66 // 2. Wait until the index is queryable (initial sync complete).
    67 fmt.Println("Polling to check if the index is ready. This may take up to a minute.")
    68 if err := waitForIndexQueryable(ctx, coll, indexName); err != nil {
    69 log.Fatalf("Error while waiting for index to become queryable: %v", err)
    70 }
    71 fmt.Println(indexName, "is ready for querying.")
    72}
    73
    74func createAutoEmbeddingIndex(ctx context.Context, coll *mongo.Collection) error {
    75 // Define the index fields.
    76 definition := autoEmbedIndexDefinition{
    77 Fields: []any{
    78 autoEmbedField{
    79 Type: "autoEmbed",
    80 Modality: "text",
    81 Path: "fullplot",
    82 Model: "voyage-4",
    83 },
    84 },
    85 }
    86
    87 // Set index name and type "vectorSearch".
    88 opts := options.SearchIndexes().
    89 SetName(indexName).
    90 SetType("vectorSearch")
    91
    92 model := mongo.SearchIndexModel{
    93 Definition: definition,
    94 Options: opts,
    95 }
    96
    97 _, err := coll.SearchIndexes().CreateOne(ctx, model)
    98 return err
    99}
    100
    101func waitForIndexQueryable(ctx context.Context, coll *mongo.Collection, name string) error {
    102 for {
    103 // List just this index by name.
    104 opts := options.SearchIndexes().SetName(name)
    105 cursor, err := coll.SearchIndexes().List(ctx, opts)
    106 if err != nil {
    107 return fmt.Errorf("list search indexes: %w", err)
    108 }
    109
    110 var results []bson.M
    111 if err := cursor.All(ctx, &results); err != nil {
    112 return fmt.Errorf("decode search index list: %w", err)
    113 }
    114
    115 if len(results) > 0 {
    116 if q, ok := results[0]["queryable"].(bool); ok && q {
    117 return nil
    118 }
    119 }
    120
    121 select {
    122 case <-ctx.Done():
    123 return ctx.Err()
    124 case <-time.After(5 * time.Second):
    125 // Continue polling.
    126 }
    127 }
    128}
    129
    130// end-create-index

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connection-string> placeholder in the index definition with your deployment's connection string and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following command:

go run create-index.go
1

To define a MongoDB Vector Search index:

  1. Create a .java file.

    touch vectorIndex.java
  2. Copy and paste the following index definition in to the file.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vectorIndex.java
    1import com.mongodb.client.MongoClient;
    2import com.mongodb.client.MongoClients;
    3import com.mongodb.client.MongoCollection;
    4import com.mongodb.client.MongoDatabase;
    5import com.mongodb.client.model.SearchIndexModel;
    6import com.mongodb.client.model.SearchIndexType;
    7import org.bson.Document;
    8
    9import java.util.Arrays;
    10import java.util.Collections;
    11
    12public class CreateIndex {
    13 public static void main(String[] args) throws InterruptedException {
    14 // connect to your deployment
    15 String uri = "<connectionString>";
    16
    17 try (MongoClient client = MongoClients.create(uri)) {
    18 MongoDatabase database = client.getDatabase("sample_mflix");
    19 MongoCollection<Document> collection = database.getCollection("movies");
    20
    21 // define your MongoDB Vector Search index
    22 SearchIndexModel indexModel = new SearchIndexModel(
    23 "autoembed_index",
    24 new Document("fields",
    25 Arrays.asList(
    26 new Document("type", "autoEmbed")
    27 .append("modality", "text")
    28 .append("path", "fullplot")
    29 .append("model", "voyage-4")
    30 )
    31 ),
    32 SearchIndexType.vectorSearch()
    33 );
    34
    35 // run the helper method
    36 String result = collection.createSearchIndexes(Collections.singletonList(indexModel)).get(0);
    37 System.out.println("New search index named " + result + " is building.");
    38
    39 System.out.println("Polling to check if the index is ready. This may take up to a minute.");
    40 boolean isQueryable = false;
    41 while (!isQueryable) {
    42 for (Document index : collection.listSearchIndexes()) {
    43 if (result.equals(index.getString("name"))) {
    44 String status = index.getString("status");
    45 if ("READY".equals(status) || status == null) {
    46 System.out.println(result + " is ready for querying.");
    47 isQueryable = true;
    48 }
    49 break;
    50 }
    51 }
    52
    53 // wait for the index to be ready to query
    54 if (!isQueryable) {
    55 Thread.sleep(5000);
    56 }
    57 }
    58 }
    59 }
    60}

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connectionString> in the index definition and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following commands:

javac vectorIndex.java
java vectorIndex
1

To define a MongoDB Vector Search index:

  1. Create a .js file.

    touch vector_index.js
  2. Copy and paste the following index definition in to the file.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vector_index.js
    1const { MongoClient } = require("mongodb");
    2const { setTimeout } = require("timers/promises");
    3
    4const uri = "<CONNECTION-STRING>";
    5const client = new MongoClient(uri);
    6
    7async function run() {
    8 try {
    9 const database = client.db("sample_mflix");
    10 const collection = database.collection("movies");
    11
    12 // define your MongoDB Vector Search index
    13 const index = {
    14 name: "autoembed_index",
    15 type: "vectorSearch",
    16 definition: {
    17 fields: [
    18 {
    19 type: "autoEmbed",
    20 modality: "text",
    21 path: "fullplot",
    22 model: "voyage-4"
    23 }
    24 ]
    25 }
    26 };
    27
    28 // run the helper method
    29 const result = await collection.createSearchIndex(index);
    30 console.log(`New search index named ${result} is building.`);
    31
    32 console.log("Polling to check if the index is ready. This may take up to a minute.");
    33 let isQueryable = false;
    34 while (!isQueryable) {
    35 const [indexData] = await collection.listSearchIndexes(index.name).toArray();
    36 if (indexData) {
    37 isQueryable = indexData.queryable;
    38 if (!isQueryable) {
    39 await setTimeout(5000);
    40 }
    41 } else {
    42 console.log(`Index ${index.name} not found.`);
    43 await setTimeout(5000);
    44 }
    45 }
    46 console.log(`${result} is ready for querying.`);
    47 } finally {
    48 await client.close();
    49 }
    50}
    51
    52run().catch(console.dir);

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connectionString> in the index definition and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following command:

node vector_index.js
1

To define a MongoDB Vector Search index:

  1. Create a .py file.

    touch vector_index.py
  2. Copy and paste the following index definition in to the file.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vector_index.py
    1import time
    2from pymongo import MongoClient
    3from pymongo.operations import SearchIndexModel
    4
    5client = MongoClient("<CONNECTION-STRING>")
    6collection = client["sample_mflix"]["movies"]
    7
    8# define your MongoDB Vector Search index
    9search_index_model = SearchIndexModel(
    10 definition={
    11 "fields": [
    12 {
    13 "type": "autoEmbed",
    14 "modality": "text",
    15 "path": "fullplot",
    16 "model": "voyage-4"
    17 }
    18 ]
    19 },
    20 name="autoembed_index",
    21 type="vectorSearch",
    22)
    23
    24# run the helper method
    25result = collection.create_search_index(model=search_index_model)
    26print(f"New search index named {result} is building.")
    27
    28print("Polling to check if the index is ready. This may take up to a minute.")
    29while True:
    30 indices = list(collection.list_search_indexes(result))
    31 if len(indices) and indices[0].get("queryable"):
    32 break
    33 time.sleep(5)
    34print(f"{result} is ready for querying.")

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connectionString> in the index definition and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following command:

python vector_index.py
1

For detailed installation instructions, refer to the MongoDB C++ Driver documentation.

2
mkdir query-quick-start
3
cd query-quick-start
touch CMakeLists.txt

Copy and paste the following lines into the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.30)
project(query_quick_start)
set(CMAKE_CXX_STANDARD 17)
# You must use mongocxx driver version 3.11.0 or later to
# create a vector index.
find_package(mongocxx REQUIRED)
find_package(bsoncxx REQUIRED)
add_executable(query_quick_start
vector_index.cpp
)
target_link_libraries(query_quick_start PRIVATE mongo::mongocxx_shared)
target_link_libraries(query_quick_start PRIVATE mongo::bsoncxx_shared)
4

Create a file named vector_index.cpp. Copy and paste the following code into the file.

vector_index.cpp
1#include <bsoncxx/builder/basic/document.hpp>
2#include <iostream>
3#include <mongocxx/client.hpp>
4#include <mongocxx/instance.hpp>
5#include <mongocxx/search_index_view.hpp>
6#include <mongocxx/uri.hpp>
7#include <thread>
8
9using bsoncxx::builder::basic::kvp;
10using bsoncxx::builder::basic::make_array;
11using bsoncxx::builder::basic::make_document;
12
13int main() {
14 try {
15 mongocxx::instance inst{};
16
17 // Replace the placeholder with your connection string
18 const auto uri = mongocxx::uri{"<connection-string>"};
19
20 // Connect to your cluster
21 mongocxx::client conn{uri};
22 auto db = conn["sample_mflix"];
23 auto collection = db["movies"];
24
25 auto siv = collection.search_indexes();
26 std::string name = "autoembed_index";
27 auto type = "vectorSearch";
28 auto definition = make_document(
29 kvp("fields",
30 make_array(make_document(
31 kvp("type", "autoEmbed"), kvp("modality", "text"),
32 kvp("path", "fullplot"), kvp("model", "voyage-4")))));
33 auto model =
34 mongocxx::search_index_model(name, definition.view()).type(type);
35 siv.create_one(model);
36 std::cout << "New search index named " << name << " is building."
37 << std::endl;
38
39 // Polling for index status
40 std::cout << "Polling to check if the index is ready. This may take up to "
41 "a minute."
42 << std::endl;
43 bool queryable = false;
44 while (!queryable) {
45 auto indexes = siv.list();
46 for (const auto& index : indexes) {
47 if (index["name"].get_value() == name) {
48 queryable = index["queryable"].get_bool();
49 }
50 }
51 if (!queryable) {
52 std::this_thread::sleep_for(std::chrono::seconds(5));
53 }
54 }
55 std::cout << name << " is ready for querying." << std::endl;
56 } catch (const std::exception& e) {
57 std::cout << "Exception: " << e.what() << std::endl;
58 }
59 return 0;
60}

For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

This code also includes a polling mechanism to check if the index is ready to use.

5

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

6
cmake -B build
7
cmake --build build
8
./query_quick_start
1New search index named autoembed_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3autoembed_index is ready for querying.

Note

Vector Search Index supports both asynchronous and synchronous runtimes. In the following steps, select your preferred runtime to learn how to create a Vector Search Index for it.

1

Select the tab for the runtime that you use and run the following commands to add the required dependencies:

cargo add mongodb
cargo add tokio --features full
cargo add futures

For further information about Rust with MongoDB, see the MongoDB Rust Driver documentation.

2

In the /src directory of your project, create a file named vector_index.rs, then copy and paste the following code into the file.

This index definition:

  • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

  • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

This code also includes a polling mechanism to check if the index is ready to use.

vector_index.rs
1use std::ops::Index;
2use std::time::Duration;
3use futures::{TryStreamExt};
4use mongodb::{bson::{Document, doc}, Client, Collection, SearchIndexModel};
5use mongodb::SearchIndexType::VectorSearch;
6use tokio::time::sleep;
7
8#[tokio::main]
9pub(crate) async fn vector_index() {
10 // Replace the placeholder with your connection string
11 let uri = "<connection-string>";
12
13 // Create a new client and connect to the server
14 let client = Client::with_uri_str(uri).await.unwrap();
15
16 // Get a handle on the movies collection
17 let database = client.database("sample_mflix");
18 let my_coll: Collection<Document> = database.collection("movies");
19
20 let index_name = "autoembed_index";
21 let search_index_def = SearchIndexModel::builder()
22 .definition(doc! {
23 "fields": vec! {doc! {
24 "type": "autoEmbed",
25 "modality": "text",
26 "path": "fullplot",
27 "model": "voyage-4"
28 }}
29 })
30 .name(index_name.to_string())
31 .index_type(VectorSearch)
32 .build();
33
34 let models = vec![search_index_def];
35 let result = my_coll.create_search_indexes(models).await;
36 if let Err(e) = result {
37 eprintln!("There was an error creating the search index: {}", e);
38 std::process::exit(1)
39 } else {
40 println!("New search index named {} is building.", result.unwrap().index(0));
41 }
42
43 // Polling for the index to become queryable
44 println!("Polling to check if the index is ready. This may take up to a minute.");
45 let mut is_index_queryable = false;
46 while !is_index_queryable {
47 // List the search indexes
48 let mut search_indexes = my_coll.list_search_indexes().await.unwrap();
49 // Check if the index is present and queryable
50 while let Some(index) = search_indexes.try_next().await.unwrap() {
51 let retrieved_name = index.get_str("name");
52 if retrieved_name.unwrap().to_string() == index_name {
53 is_index_queryable = index.get_bool("queryable").unwrap();
54 }
55 }
56 if !is_index_queryable {
57 sleep(Duration::from_secs(5)).await; // Wait for 5 seconds before polling again
58 }
59 }
60 println!("{} is ready for querying.", index_name);
61}
3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
mod vector_index;
fn main() {
vector_index::vector_index();
}
5
cargo run
New search index named autoembed_index is building.
Polling to check if the index is ready. This action may take up to a minute.
autoembed_index is ready for querying.
1

To learn more, see Connect to a Cluster via Compass.

2

On the Database screen, expand the name of the database, sample_mflix, then click the name of the collection, movies.

3
  1. Click the Indexes tab, then select Search Indexes.

  2. Click Create Search Index to open the index creation dialog box.

  3. Enter autoembed_index as the name of the index.

  4. Define the MongoDB Vector Search index.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vector_index
    1{
    2 "fields": [
    3 {
    4 "type": "autoEmbed",
    5 "modality": "text",
    6 "path": "fullplot",
    7 "model": "voyage-4"
    8 }
    9 ]
    10}

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  5. Click Create Search Index.

1

Open mongosh in a terminal window and connect to your Atlas cluster. For detailed instructions on connecting, see Connect via mongosh.

2

Example

use sample_mflix
switched to db sample_mflix
3

You can create an index of autoEmbed type to run natural language queries.

1db.movies.createSearchIndex(
2 "autoembed_index",
3 "vectorSearch",
4 {
5 "fields": [
6 {
7 "type": "autoEmbed",
8 "modality": "text",
9 "path": "fullplot",
10 "model": "voyage-4"
11 }
12 ]
13 }
14);

This index definition:

  • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

  • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

1

To define a MongoDB Vector Search index:

  1. In your shell, run the following commands to create a directory called VectorSearch and initialize a .NET Framework project for a new console application:

    mkdir VectorSearch
    cd VectorSearch
    dotnet new console
  2. Run the following command to install the current version of the .NET/C# driver as a dependency of your project:

    dotnet add package MongoDB.Driver
  3. Copy and paste the following code into the Program.cs file in your application:

    Program.cs
    1using MongoDB.Bson;
    2using MongoDB.Driver;
    3
    4var connectionString = "<connection string>";
    5var client = new MongoClient(connectionString);
    6var database = client.GetDatabase("sample_mflix");
    7var collection = database.GetCollection<BsonDocument>("movies");
    8
    9var searchIndexView = collection.SearchIndexes;
    10var name = "autembed_index";
    11
    12var definition = new BsonDocument
    13{
    14 { "fields", new BsonArray
    15 {
    16 new BsonDocument
    17 {
    18 { "type", "autoEmbed" },
    19 { "modality", "text" },
    20 { "path", "fullplot" },
    21 { "model", "voyage-4" }
    22 }
    23 }
    24 }
    25};
    26
    27var model = new CreateSearchIndexModel(name, SearchIndexType.VectorSearch, definition);
    28searchIndexView.CreateOne(model);
    29Console.WriteLine($"New search index named {name} is building.");
    30
    31Console.WriteLine("Polling to check if the index is ready.");
    32bool queryable = false;
    33while (!queryable)
    34{
    35 var indexes = searchIndexView.List();
    36 foreach (var index in indexes.ToEnumerable())
    37 {
    38 if (index["name"] == name)
    39 {
    40 queryable = index["queryable"].AsBoolean;
    41 }
    42 }
    43 if (!queryable)
    44 {
    45 Thread.Sleep(5000);
    46 }
    47}
    48Console.WriteLine($"{name} is ready for querying.");

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

To create the index, run the following command:

dotnet run
1

To define a MongoDB Vector Search auto-embedding index, complete the following steps:

  1. Run the following command in your terminal to create a .go file in a Go project directory:

    touch create-index.go
  2. Copy and paste the following index definition into the file:

    create-index.go
    1// create-index.go
    2//
    3// This example creates an auto-embedding MongoDB Vector Search index
    4// on the "fullplot" field of the sample_mflix.movies collection.
    5// The index uses the "voyage-4" model.
    6// start-create-index
    7package main
    8
    9import (
    10 "context"
    11 "fmt"
    12 "log"
    13 "time"
    14
    15 "go.mongodb.org/mongo-driver/v2/bson"
    16 "go.mongodb.org/mongo-driver/v2/mongo"
    17 "go.mongodb.org/mongo-driver/v2/mongo/options"
    18)
    19
    20const (
    21 indexName = "autoembed_index"
    22)
    23
    24// autoEmbedField represents the auto-embedding index field definition.
    25type autoEmbedField struct {
    26 Type string `bson:"type"` // "autoEmbed"
    27 Modality string `bson:"modality"` // "text"
    28 Path string `bson:"path"` // e.g. "fullplot"
    29 Model string `bson:"model"` // e.g. "voyage-4"
    30}
    31
    32// autoEmbedIndexDefinition is the top-level index definition.
    33type autoEmbedIndexDefinition struct {
    34 Fields []any `bson:"fields"`
    35}
    36
    37func main() {
    38 // Replace with your MongoDB connection string.
    39 uri := "<connection-string>"
    40
    41 // Create a context with a timeout for index creation and polling.
    42 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
    43 defer cancel()
    44
    45 // Connect to your deployment.
    46 client, err := mongo.Connect(options.Client().ApplyURI(uri))
    47 if err != nil {
    48 log.Fatalf("Failed to connect to MongoDB: %v", err)
    49 }
    50 defer func() {
    51 if err := client.Disconnect(context.Background()); err != nil {
    52 log.Printf("Error disconnecting client: %v", err)
    53 }
    54 }()
    55
    56 // Access your database and collection.
    57 db := client.Database("sample_mflix")
    58 coll := db.Collection("movies")
    59
    60 // 1. Create the auto-embedding vectorSearch index.
    61 if err := createAutoEmbeddingIndex(ctx, coll); err != nil {
    62 log.Fatalf("Failed to create auto-embedding index: %v", err)
    63 }
    64 fmt.Println("New search index named", indexName, "is building.")
    65
    66 // 2. Wait until the index is queryable (initial sync complete).
    67 fmt.Println("Polling to check if the index is ready. This may take up to a minute.")
    68 if err := waitForIndexQueryable(ctx, coll, indexName); err != nil {
    69 log.Fatalf("Error while waiting for index to become queryable: %v", err)
    70 }
    71 fmt.Println(indexName, "is ready for querying.")
    72}
    73
    74func createAutoEmbeddingIndex(ctx context.Context, coll *mongo.Collection) error {
    75 // Define the index fields.
    76 definition := autoEmbedIndexDefinition{
    77 Fields: []any{
    78 autoEmbedField{
    79 Type: "autoEmbed",
    80 Modality: "text",
    81 Path: "fullplot",
    82 Model: "voyage-4",
    83 },
    84 },
    85 }
    86
    87 // Set index name and type "vectorSearch".
    88 opts := options.SearchIndexes().
    89 SetName(indexName).
    90 SetType("vectorSearch")
    91
    92 model := mongo.SearchIndexModel{
    93 Definition: definition,
    94 Options: opts,
    95 }
    96
    97 _, err := coll.SearchIndexes().CreateOne(ctx, model)
    98 return err
    99}
    100
    101func waitForIndexQueryable(ctx context.Context, coll *mongo.Collection, name string) error {
    102 for {
    103 // List just this index by name.
    104 opts := options.SearchIndexes().SetName(name)
    105 cursor, err := coll.SearchIndexes().List(ctx, opts)
    106 if err != nil {
    107 return fmt.Errorf("list search indexes: %w", err)
    108 }
    109
    110 var results []bson.M
    111 if err := cursor.All(ctx, &results); err != nil {
    112 return fmt.Errorf("decode search index list: %w", err)
    113 }
    114
    115 if len(results) > 0 {
    116 if q, ok := results[0]["queryable"].(bool); ok && q {
    117 return nil
    118 }
    119 }
    120
    121 select {
    122 case <-ctx.Done():
    123 return ctx.Err()
    124 case <-time.After(5 * time.Second):
    125 // Continue polling.
    126 }
    127 }
    128}
    129
    130// end-create-index

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connection-string> placeholder in the index definition with your deployment's connection string and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following command:

go run create-index.go
1

To define a MongoDB Vector Search index:

  1. Create a .java file.

    touch vectorIndex.java
  2. Copy and paste the following index definition in to the file.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vectorIndex.java
    1import com.mongodb.client.MongoClient;
    2import com.mongodb.client.MongoClients;
    3import com.mongodb.client.MongoCollection;
    4import com.mongodb.client.MongoDatabase;
    5import com.mongodb.client.model.SearchIndexModel;
    6import com.mongodb.client.model.SearchIndexType;
    7import org.bson.Document;
    8
    9import java.util.Arrays;
    10import java.util.Collections;
    11
    12public class CreateIndex {
    13 public static void main(String[] args) throws InterruptedException {
    14 // connect to your deployment
    15 String uri = "<connectionString>";
    16
    17 try (MongoClient client = MongoClients.create(uri)) {
    18 MongoDatabase database = client.getDatabase("sample_mflix");
    19 MongoCollection<Document> collection = database.getCollection("movies");
    20
    21 // define your MongoDB Vector Search index
    22 SearchIndexModel indexModel = new SearchIndexModel(
    23 "autoembed_index",
    24 new Document("fields",
    25 Arrays.asList(
    26 new Document("type", "autoEmbed")
    27 .append("modality", "text")
    28 .append("path", "fullplot")
    29 .append("model", "voyage-4")
    30 )
    31 ),
    32 SearchIndexType.vectorSearch()
    33 );
    34
    35 // run the helper method
    36 String result = collection.createSearchIndexes(Collections.singletonList(indexModel)).get(0);
    37 System.out.println("New search index named " + result + " is building.");
    38
    39 System.out.println("Polling to check if the index is ready. This may take up to a minute.");
    40 boolean isQueryable = false;
    41 while (!isQueryable) {
    42 for (Document index : collection.listSearchIndexes()) {
    43 if (result.equals(index.getString("name"))) {
    44 String status = index.getString("status");
    45 if ("READY".equals(status) || status == null) {
    46 System.out.println(result + " is ready for querying.");
    47 isQueryable = true;
    48 }
    49 break;
    50 }
    51 }
    52
    53 // wait for the index to be ready to query
    54 if (!isQueryable) {
    55 Thread.sleep(5000);
    56 }
    57 }
    58 }
    59 }
    60}

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connectionString> in the index definition and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following commands:

javac vectorIndex.java
java vectorIndex
1

To define a MongoDB Vector Search index:

  1. Create a .js file.

    touch vector_index.js
  2. Copy and paste the following index definition in to the file.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vector_index.js
    1const { MongoClient } = require("mongodb");
    2const { setTimeout } = require("timers/promises");
    3
    4const uri = "<CONNECTION-STRING>";
    5const client = new MongoClient(uri);
    6
    7async function run() {
    8 try {
    9 const database = client.db("sample_mflix");
    10 const collection = database.collection("movies");
    11
    12 // define your MongoDB Vector Search index
    13 const index = {
    14 name: "autoembed_index",
    15 type: "vectorSearch",
    16 definition: {
    17 fields: [
    18 {
    19 type: "autoEmbed",
    20 modality: "text",
    21 path: "fullplot",
    22 model: "voyage-4"
    23 }
    24 ]
    25 }
    26 };
    27
    28 // run the helper method
    29 const result = await collection.createSearchIndex(index);
    30 console.log(`New search index named ${result} is building.`);
    31
    32 console.log("Polling to check if the index is ready. This may take up to a minute.");
    33 let isQueryable = false;
    34 while (!isQueryable) {
    35 const [indexData] = await collection.listSearchIndexes(index.name).toArray();
    36 if (indexData) {
    37 isQueryable = indexData.queryable;
    38 if (!isQueryable) {
    39 await setTimeout(5000);
    40 }
    41 } else {
    42 console.log(`Index ${index.name} not found.`);
    43 await setTimeout(5000);
    44 }
    45 }
    46 console.log(`${result} is ready for querying.`);
    47 } finally {
    48 await client.close();
    49 }
    50}
    51
    52run().catch(console.dir);

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connectionString> in the index definition and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following command:

node vector_index.js
1

To define a MongoDB Vector Search index:

  1. Create a .py file.

    touch vector_index.py
  2. Copy and paste the following index definition in to the file.

    This index definition:

    • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

    • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

    vector_index.py
    1import time
    2from pymongo import MongoClient
    3from pymongo.operations import SearchIndexModel
    4
    5client = MongoClient("<CONNECTION-STRING>")
    6collection = client["sample_mflix"]["movies"]
    7
    8# define your MongoDB Vector Search index
    9search_index_model = SearchIndexModel(
    10 definition={
    11 "fields": [
    12 {
    13 "type": "autoEmbed",
    14 "modality": "text",
    15 "path": "fullplot",
    16 "model": "voyage-4"
    17 }
    18 ]
    19 },
    20 name="autoembed_index",
    21 type="vectorSearch",
    22)
    23
    24# run the helper method
    25result = collection.create_search_index(model=search_index_model)
    26print(f"New search index named {result} is building.")
    27
    28print("Polling to check if the index is ready. This may take up to a minute.")
    29while True:
    30 indices = list(collection.list_search_indexes(result))
    31 if len(indices) and indices[0].get("queryable"):
    32 break
    33 time.sleep(5)
    34print(f"{result} is ready for querying.")

    For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

  3. Replace the <connectionString> in the index definition and save the file.

    To learn more, see Connect to a Cluster via Client Libraries.

2

To create the index, run the following command:

python vector_index.py
1

For detailed installation instructions, refer to the MongoDB C++ Driver documentation.

2
mkdir query-quick-start
3
cd query-quick-start
touch CMakeLists.txt

Copy and paste the following lines into the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.30)
project(query_quick_start)
set(CMAKE_CXX_STANDARD 17)
# You must use mongocxx driver version 3.11.0 or later to
# create a vector index.
find_package(mongocxx REQUIRED)
find_package(bsoncxx REQUIRED)
add_executable(query_quick_start
vector_index.cpp
)
target_link_libraries(query_quick_start PRIVATE mongo::mongocxx_shared)
target_link_libraries(query_quick_start PRIVATE mongo::bsoncxx_shared)
4

Create a file named vector_index.cpp. Copy and paste the following code into the file.

vector_index.cpp
1#include <bsoncxx/builder/basic/document.hpp>
2#include <iostream>
3#include <mongocxx/client.hpp>
4#include <mongocxx/instance.hpp>
5#include <mongocxx/search_index_view.hpp>
6#include <mongocxx/uri.hpp>
7#include <thread>
8
9using bsoncxx::builder::basic::kvp;
10using bsoncxx::builder::basic::make_array;
11using bsoncxx::builder::basic::make_document;
12
13int main() {
14 try {
15 mongocxx::instance inst{};
16
17 // Replace the placeholder with your connection string
18 const auto uri = mongocxx::uri{"<connection-string>"};
19
20 // Connect to your cluster
21 mongocxx::client conn{uri};
22 auto db = conn["sample_mflix"];
23 auto collection = db["movies"];
24
25 auto siv = collection.search_indexes();
26 std::string name = "autoembed_index";
27 auto type = "vectorSearch";
28 auto definition = make_document(
29 kvp("fields",
30 make_array(make_document(
31 kvp("type", "autoEmbed"), kvp("modality", "text"),
32 kvp("path", "fullplot"), kvp("model", "voyage-4")))));
33 auto model =
34 mongocxx::search_index_model(name, definition.view()).type(type);
35 siv.create_one(model);
36 std::cout << "New search index named " << name << " is building."
37 << std::endl;
38
39 // Polling for index status
40 std::cout << "Polling to check if the index is ready. This may take up to "
41 "a minute."
42 << std::endl;
43 bool queryable = false;
44 while (!queryable) {
45 auto indexes = siv.list();
46 for (const auto& index : indexes) {
47 if (index["name"].get_value() == name) {
48 queryable = index["queryable"].get_bool();
49 }
50 }
51 if (!queryable) {
52 std::this_thread::sleep_for(std::chrono::seconds(5));
53 }
54 }
55 std::cout << name << " is ready for querying." << std::endl;
56 } catch (const std::exception& e) {
57 std::cout << "Exception: " << e.what() << std::endl;
58 }
59 return 0;
60}

For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

This code also includes a polling mechanism to check if the index is ready to use.

5

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

6
cmake -B build
7
cmake --build build
8
./query_quick_start
1New search index named autoembed_index is building.
2Polling to check if the index is ready. This may take up to a minute.
3autoembed_index is ready for querying.

Note

Vector Search Index supports both asynchronous and synchronous runtimes. In the following steps, select your preferred runtime to learn how to create a Vector Search Index for it.

1

Select the tab for the runtime that you use and run the following commands to add the required dependencies:

cargo add mongodb
cargo add tokio --features full
cargo add futures

For further information about Rust with MongoDB, see the MongoDB Rust Driver documentation.

2

In the /src directory of your project, create a file named vector_index.rs, then copy and paste the following code into the file.

This index definition:

  • Indexes the fullplot field as the autoEmbed type. This field contains text that represent the summary of a movie's plot.

  • Uses voyage-4 embedding model to generate the vector embeddings for the fullplot field.

For details on all the MongoDB Vector Search index settings for Automated Embedding, see MongoDB Vector Search Index Fields.

This code also includes a polling mechanism to check if the index is ready to use.

vector_index.rs
1use std::ops::Index;
2use std::time::Duration;
3use futures::{TryStreamExt};
4use mongodb::{bson::{Document, doc}, Client, Collection, SearchIndexModel};
5use mongodb::SearchIndexType::VectorSearch;
6use tokio::time::sleep;
7
8#[tokio::main]
9pub(crate) async fn vector_index() {
10 // Replace the placeholder with your connection string
11 let uri = "<connection-string>";
12
13 // Create a new client and connect to the server
14 let client = Client::with_uri_str(uri).await.unwrap();
15
16 // Get a handle on the movies collection
17 let database = client.database("sample_mflix");
18 let my_coll: Collection<Document> = database.collection("movies");
19
20 let index_name = "autoembed_index";
21 let search_index_def = SearchIndexModel::builder()
22 .definition(doc! {
23 "fields": vec! {doc! {
24 "type": "autoEmbed",
25 "modality": "text",
26 "path": "fullplot",
27 "model": "voyage-4"
28 }}
29 })
30 .name(index_name.to_string())
31 .index_type(VectorSearch)
32 .build();
33
34 let models = vec![search_index_def];
35 let result = my_coll.create_search_indexes(models).await;
36 if let Err(e) = result {
37 eprintln!("There was an error creating the search index: {}", e);
38 std::process::exit(1)
39 } else {
40 println!("New search index named {} is building.", result.unwrap().index(0));
41 }
42
43 // Polling for the index to become queryable
44 println!("Polling to check if the index is ready. This may take up to a minute.");
45 let mut is_index_queryable = false;
46 while !is_index_queryable {
47 // List the search indexes
48 let mut search_indexes = my_coll.list_search_indexes().await.unwrap();
49 // Check if the index is present and queryable
50 while let Some(index) = search_indexes.try_next().await.unwrap() {
51 let retrieved_name = index.get_str("name");
52 if retrieved_name.unwrap().to_string() == index_name {
53 is_index_queryable = index.get_bool("queryable").unwrap();
54 }
55 }
56 if !is_index_queryable {
57 sleep(Duration::from_secs(5)).await; // Wait for 5 seconds before polling again
58 }
59 }
60 println!("{} is ready for querying.", index_name);
61}
3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
mod vector_index;
fn main() {
vector_index::vector_index();
}
5
cargo run
New search index named autoembed_index is building.
Polling to check if the index is ready. This action may take up to a minute.
autoembed_index is ready for querying.

In this section, you run a sample MongoDB Vector Search query on your indexed field.

In this section, you run a sample vector search query on your indexed embeddings. To execute the query, use mongosh or a supported driver. The following example uses mongosh to run the query:

1
  1. Create a file named query-embeddings.js to store the query embeddings.

  2. Copy and paste the following embeddings for the string time travel into the query-embeddings.js file.

    QUERY_EMBEDDING = [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234];
  3. Save the query-embeddings.js file.

2

In mongosh, run the following command, replacing <path-to-file> with the complete path to your query-embeddings.js file.

load('/<path-to-file>/query-embeddings.js')

You can verify if the file loaded properly by running the following command:

QUERY_EMBEDDING.length
2048
3

Copy and paste the following sample query into your terminal and then run it using mongosh.

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

1db.embedded_movies.aggregate([
2 {
3 "$vectorSearch": {
4 "index": "vector_index",
5 "path": "plot_embedding_voyage_3_large",
6 "queryVector": QUERY_EMBEDDING,
7 "numCandidates": 150,
8 "limit": 10
9 }
10 },
11 {
12 "$project": {
13 "_id": 0,
14 "plot": 1,
15 "title": 1,
16 "score": { $meta: "vectorSearchScore" }
17 }
18 }
19])
1[
2 {
3 plot: 'At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.',
4 title: 'About Time',
5 score: 0.7710106372833252
6 },
7 {
8 plot: 'A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.',
9 title: 'Retroactive',
10 score: 0.760047972202301
11 },
12 {
13 plot: 'A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...',
14 title: 'A.P.E.X.',
15 score: 0.7576861381530762
16 },
17 {
18 plot: 'An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.',
19 title: 'Timecop',
20 score: 0.7576561570167542
21 },
22 {
23 plot: 'After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.',
24 title: 'Back to the Future Part II',
25 score: 0.7521393895149231
26 },
27 {
28 plot: 'A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.',
29 title: 'Thrill Seekers',
30 score: 0.7509932518005371
31 },
32 {
33 plot: 'Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...',
34 title: 'Timerider: The Adventure of Lyle Swann',
35 score: 0.7502642869949341
36 },
37 {
38 plot: 'Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.',
39 title: 'The Time Machine',
40 score: 0.7502503395080566
41 },
42 {
43 plot: 'A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.',
44 title: "The Time Traveler's Wife",
45 score: 0.749496340751648
46 },
47 {
48 plot: 'A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.',
49 title: 'The Final Countdown',
50 score: 0.7469133734703064
51 }
52]

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

1
  1. Create a file named query-embeddings.js to store the query embeddings.

  2. Copy and paste the following embeddings for the string time travel into the query-embeddings.js file.

    QUERY_EMBEDDING = [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234];
  3. Save the query-embeddings.js file.

2

In mongosh, run the following command, replacing <path-to-file> with the complete path to your query-embeddings.js file.

load('/<path-to-file>/query-embeddings.js')

You can verify if the file loaded properly by running the following command:

QUERY_EMBEDDING.length
2048
3

Copy and paste the following sample query into your terminal and then run it using mongosh.

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

1db.embedded_movies.aggregate([
2 {
3 "$vectorSearch": {
4 "index": "vector_index",
5 "path": "plot_embedding_voyage_3_large",
6 "queryVector": QUERY_EMBEDDING,
7 "numCandidates": 150,
8 "limit": 10
9 }
10 },
11 {
12 "$project": {
13 "_id": 0,
14 "plot": 1,
15 "title": 1,
16 "score": { $meta: "vectorSearchScore" }
17 }
18 }
19])
1[
2 {
3 plot: 'At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.',
4 title: 'About Time',
5 score: 0.7710106372833252
6 },
7 {
8 plot: 'A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.',
9 title: 'Retroactive',
10 score: 0.760047972202301
11 },
12 {
13 plot: 'A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...',
14 title: 'A.P.E.X.',
15 score: 0.7576861381530762
16 },
17 {
18 plot: 'An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.',
19 title: 'Timecop',
20 score: 0.7576561570167542
21 },
22 {
23 plot: 'After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.',
24 title: 'Back to the Future Part II',
25 score: 0.7521393895149231
26 },
27 {
28 plot: 'A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.',
29 title: 'Thrill Seekers',
30 score: 0.7509932518005371
31 },
32 {
33 plot: 'Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...',
34 title: 'Timerider: The Adventure of Lyle Swann',
35 score: 0.7502642869949341
36 },
37 {
38 plot: 'Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.',
39 title: 'The Time Machine',
40 score: 0.7502503395080566
41 },
42 {
43 plot: 'A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.',
44 title: "The Time Traveler's Wife",
45 score: 0.749496340751648
46 },
47 {
48 plot: 'A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.',
49 title: 'The Final Countdown',
50 score: 0.7469133734703064
51 }
52]

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.c and copy and paste the following sample query into the file:

    atlas-vector-search-quick-start.c
    1#include <bson/bson.h>
    2#include <mongoc/mongoc.h>
    3#include <stdio.h>
    4
    5int main(void) {
    6
    7 mongoc_client_t *client;
    8 mongoc_collection_t *collection;
    9 mongoc_cursor_t *cursor;
    10 bson_array_builder_t *builder;
    11 bson_t *pipeline;
    12 bson_t query_vector;
    13 bson_error_t error;
    14 const bson_t *doc;
    15 char *str;
    16
    17 int arrSize = 2048; // This collection has a vector array of 2048 dimensions; depending on your vector embedding model, this mary vary
    18 double embeddings[] = {-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234};
    19
    20 // Initialize the MongoDB C Driver
    21 mongoc_init();
    22
    23 // Connect to your Atlas collection
    24 client = mongoc_client_new("<connection-string>");
    25 collection = mongoc_client_get_collection (client, "sample_mflix", "embedded_movies");
    26
    27 // Build query vector array
    28 builder = bson_array_builder_new();
    29
    30 for(int i = 0; i < arrSize; i++){
    31 bson_array_builder_append_double(builder, embeddings[i]);
    32 }
    33
    34 bson_array_builder_build(builder, &query_vector);
    35 bson_array_builder_destroy(builder);
    36
    37 // Create aggregation pipeline for Vector Search
    38 pipeline = BCON_NEW(
    39 "pipeline",
    40 "[",
    41 "{",
    42 "$vectorSearch", "{",
    43 "index", "vector_index",
    44 "path", "plot_embedding_voyage_3_large",
    45 "queryVector", BCON_ARRAY(&query_vector),
    46 "numCandidates", BCON_INT32(150),
    47 "limit", BCON_INT32(10),
    48 "}",
    49 "}",
    50 "{",
    51 "$project", "{",
    52 "title", BCON_BOOL(true),
    53 "plot", BCON_BOOL(true),
    54 "_id", BCON_BOOL(false),
    55 "score", "{",
    56 "$meta", "vectorSearchScore",
    57 "}",
    58 "}",
    59 "}",
    60 "]"
    61 );
    62
    63 // Run query
    64 cursor = mongoc_collection_aggregate(collection, MONGOC_QUERY_NONE, pipeline, NULL, NULL );
    65
    66 // Print results
    67 while (mongoc_cursor_next (cursor, &doc)) {
    68 str = bson_as_canonical_extended_json (doc, NULL);
    69 printf ("%s\n", str);
    70 bson_free (str);
    71 }
    72
    73 // Cleanup
    74 bson_destroy(pipeline);
    75 mongoc_cursor_destroy(cursor);
    76 mongoc_collection_destroy(collection);
    77 mongoc_client_destroy(client);
    78 mongoc_cleanup();
    79
    80 return 0;
    81}

    This query uses the $vectorSearch stage to:

    • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

    • Consider up to the 150 most similar movie plots and return the top 10 results.

    It uses the $project stage to:

    • Only include the movie plot and title fields in the results.

    • Add a score field to show the relevance of each result to the search term.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3
  1. Replace the vector_index.c file name in your CMakeLists.txt file with your new atlas-vector-search-quick-start.c filename.

  2. Navigate to the /build directory, and prepare the project.

    cd build
    cmake ../
4

From your build directory, compile and run the atlas-vector-search-quick-start.c file.

cmake --build .
./atlas-vector-search-quick-start
1{ "plot" : "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title" : "About Time", "score" : { "$numberDouble" : "0.77101063728332519531" } }
2{ "plot" : "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title" : "Retroactive", "score" : { "$numberDouble" : "0.76004797220230102539" } }
3{ "plot" : "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title" : "A.P.E.X.", "score" : { "$numberDouble" : "0.75768613815307617188" } }
4{ "plot" : "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title" : "Timecop", "score" : { "$numberDouble" : "0.75765615701675415039" } }
5{ "plot" : "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title" : "Back to the Future Part II", "score" : { "$numberDouble" : "0.7521393895149230957" } }
6{ "plot" : "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title" : "Thrill Seekers", "score" : { "$numberDouble" : "0.75099325180053710938" } }
7{ "plot" : "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title" : "Timerider: The Adventure of Lyle Swann", "score" : { "$numberDouble" : "0.75026428699493408203" } }
8{ "plot" : "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title" : "The Time Machine", "score" : { "$numberDouble" : "0.75025033950805664062" } }
9{ "plot" : "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title" : "The Time Traveler's Wife", "score" : { "$numberDouble" : "0.74949634075164794922" } }
10{ "plot" : "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title" : "The Final Countdown", "score" : { "$numberDouble" : "0.74691337347030639648" } }
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas_vector_search_quick_start.cpp .

  2. Copy and paste the following sample query into the atlas_vector_search_quick_start.cpp file:

    atlas_vector_search_quick_start.cpp
    1#include <bsoncxx/builder/basic/document.hpp>
    2#include <bsoncxx/builder/list.hpp>
    3#include <bsoncxx/json.hpp>
    4#include <mongocxx/client.hpp>
    5#include <mongocxx/instance.hpp>
    6#include <mongocxx/uri.hpp>
    7
    8using bsoncxx::builder::basic::kvp;
    9using bsoncxx::builder::basic::make_document;
    10
    11int main() {
    12 try {
    13 mongocxx::instance inst{};
    14
    15 // Replace the placeholder with your Atlas connection string
    16 const auto uri = mongocxx::uri{"<connection-string>"};
    17
    18 // Connect to your cluster
    19 auto client = mongocxx::client{uri};
    20 auto db = client["sample_mflix"];
    21 auto collection = db["embedded_movies"];
    22
    23 // Define vector embeddings to search
    24 auto vectors = bsoncxx::builder::list{
    25 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234
    26 };
    27
    28 // Define the pipeline with vectorSearch query options
    29 mongocxx::pipeline stages;
    30
    31 stages
    32 .append_stage(make_document(
    33 kvp("$vectorSearch",
    34 make_document(kvp("index", "vector_index"),
    35 kvp("path", "plot_embedding_voyage_3_large"),
    36 kvp("queryVector", vectors),
    37 kvp("numCandidates", 150), kvp("limit", 10)))))
    38 .project(make_document(
    39 kvp("_id", 0), kvp("plot", 1), kvp("title", 1),
    40 kvp("score", make_document(kvp("$meta", "vectorSearchScore")))));
    41
    42 auto cursor = collection.aggregate(stages);
    43
    44 for (auto&& doc : cursor) {
    45 std::cout << bsoncxx::to_json(doc) << std::endl;
    46 }
    47 } catch (const std::exception& e) {
    48 std::cout << "Exception: " << e.what() << std::endl;
    49 }
    50 return 0;
    51}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3
  1. Replace the vector_index.cpp file name in your CMakeLists.txt file with your new atlas_vector_search_quick_start.cpp filename.

  2. Navigate to the /build directory, and prepare the project.

    cmake ../
  3. Build the app.

    cmake --build .
  4. Execute the app to run the query.

    ./query_quick_start
    1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
    2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
    3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
    4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
    5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
    6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
    7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
    8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
    9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
    10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a new file called DatabaseService.cs.

  2. Copy and paste the following sample query into the DatabaseService.cs file:

    DatabaseService.cs
    1namespace query_quick_start;
    2
    3using MongoDB.Bson;
    4using MongoDB.Bson.Serialization.Attributes;
    5using MongoDB.Bson.Serialization.Conventions;
    6using MongoDB.Driver;
    7
    8public class DatabaseService
    9{
    10 // Replace the placeholder with your Atlas connection string
    11 private const string MongoConnectionString = "<connection-string>";
    12
    13 public void RunVectorQuery(){
    14 var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
    15 ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
    16
    17 // connect to your cluster
    18 var mongoClient = new MongoClient(MongoConnectionString);
    19
    20 // define namespace
    21 var moviesDatabase = mongoClient.GetDatabase("sample_mflix");
    22 var moviesCollection = moviesDatabase.GetCollection<EmbeddedMovie>("embedded_movies");
    23
    24 // define vector embeddings to search
    25 var vector = new[] {-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234};
    26 var options = new VectorSearchOptions<EmbeddedMovie>() {
    27 IndexName = "vector_index",
    28 NumberOfCandidates = 150
    29 };
    30
    31 // run query
    32 var results = moviesCollection.Aggregate()
    33 .VectorSearch(movie => movie.Embedding, vector, 10, options)
    34 .Project(Builders<EmbeddedMovie>.Projection
    35 .Include(movie => movie.Title)
    36 .Include(movie => movie.Plot)
    37 .Exclude(movie => movie.Id)
    38 .MetaVectorSearchScore(movie => movie.Score))
    39 .ToList();
    40
    41 // print results
    42 foreach (var movie in results)
    43 {
    44 Console.WriteLine(movie.ToJson());
    45 }
    46 }
    47}
    48
    49[BsonIgnoreExtraElements]
    50public class EmbeddedMovie
    51{
    52 [BsonIgnoreIfDefault]
    53 public ObjectId Id { get; set; }
    54 public string? Title { get; set; }
    55 public string? Plot { get; set; }
    56 [BsonElement("plot_embedding_voyage_3_large")]
    57 public double[]? Embedding { get; set; }
    58 public double Score { get; set; }
    59}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Remove the index creation code from your Program.cs file. Instead, initialize the DatabaseService object and call the method to run the query:

Program.cs
using query_quick_start;
var databaseService = new DatabaseService();
databaseService.RunVectorQuery();
4

Compile and run your project.

dotnet run query-quick-start.csproj
1{ "plot" : "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title" : "About Time", "score" : 0.7710106372833252 }
2{ "plot" : "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title" : "Retroactive", "score" : 0.76004797220230103 }
3{ "plot" : "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title" : "A.P.E.X.", "score" : 0.75768613815307617 }
4{ "plot" : "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title" : "Timecop", "score" : 0.75765615701675415 }
5{ "plot" : "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title" : "Back to the Future Part II", "score" : 0.7521393895149231 }
6{ "plot" : "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title" : "Thrill Seekers", "score" : 0.75099325180053711 }
7{ "plot" : "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title" : "Timerider: The Adventure of Lyle Swann", "score" : 0.75026428699493408 }
8{ "plot" : "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title" : "The Time Machine", "score" : 0.75025033950805664 }
9{ "plot" : "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title" : "The Time Traveler's Wife", "score" : 0.74949634075164795 }
10{ "plot" : "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title" : "The Final Countdown", "score" : 0.7469133734703064 }
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named BasicQuery.java.

  2. Copy and paste the following sample query into the BasicQuery.java file:

    1import com.mongodb.client.MongoClient;
    2import com.mongodb.client.MongoClients;
    3import com.mongodb.client.MongoCollection;
    4import com.mongodb.client.MongoDatabase;
    5import com.mongodb.client.model.search.FieldSearchPath;
    6import org.bson.Document;
    7import org.bson.conversions.Bson;
    8
    9import java.util.List;
    10
    11import static com.mongodb.client.model.Aggregates.project;
    12import static com.mongodb.client.model.Aggregates.vectorSearch;
    13import static com.mongodb.client.model.Projections.fields;
    14import static com.mongodb.client.model.Projections.include;
    15import static com.mongodb.client.model.Projections.exclude;
    16import static com.mongodb.client.model.Projections.metaVectorSearchScore;
    17import static com.mongodb.client.model.search.SearchPath.fieldPath;
    18import static com.mongodb.client.model.search.VectorSearchOptions.approximateVectorSearchOptions;
    19import static java.util.Arrays.asList;
    20
    21public class BasicQuery {
    22 public static void main( String[] args ) {
    23 // specify connection
    24 String uri = "<connection-string>";
    25
    26 // establish connection and set namespace
    27 try (MongoClient mongoClient = MongoClients.create(uri)) {
    28 MongoDatabase database = mongoClient.getDatabase("sample_mflix");
    29 MongoCollection<Document> collection = database.getCollection("embedded_movies");
    30
    31
    32 // define $vectorSearch query options
    33 List<Double> queryVector = (asList(-0.034731735d,0.008558298d,-0.0153717d,-0.029912498d,0.011549547d,0.010261648d,-0.011964999d,-0.023265276d,0.010303194d,-0.006896493d,-0.00054528d,0.003926015d,-0.025757983d,0.027419789d,0.001199616d,-0.036227357d,-0.005297005d,0.021935832d,0.010303194d,-0.019193852d,0.025093261d,-0.040049512d,-0.033900831d,-0.011466458d,-0.01827986d,-0.0153717d,0.023265276d,0.007727395d,0.000114249d,0.005317777d,-0.043871664d,-0.02127111d,-0.019609304d,0.016368784d,-0.004756918d,0.003552109d,0.006522586d,-0.005400868d,-0.015620971d,-0.034565553d,-0.018695312d,-0.023099095d,0.050851244d,-0.034731735d,0.004819236d,0.022268193d,-0.095719993d,0.05517194d,-0.046198189d,-0.036393538d,0.007187308d,-0.02459472d,-0.036725901d,0.009472291d,0.019027673d,0.020938748d,-0.011051006d,0.027087428d,0.04586583d,-0.022600554d,-0.05517194d,0.044204023d,0.01213118d,0.047859997d,-0.03938479d,0.002928932d,0.002056484d,0.019443123d,-0.028583053d,0.013543714d,0.022932915d,0.011632638d,0.004923099d,0.000389486d,0.020024756d,-0.024096178d,-0.022766734d,0.011217186d,-0.003198975d,0.007104218d,-0.047195274d,-0.013377533d,0.013294443d,0.024096178d,-0.056501385d,-0.026755067d,-0.008433662d,-0.001911076d,0.007976666d,-0.008101301d,-0.014042255d,0.008641388d,-0.02176965d,0.010012378d,-0.000607598d,-0.024927082d,0.024927082d,-0.018612221d,-0.001184036d,0.005567048d,0.001324251d,-0.019526213d,-0.023597637d,0.060489718d,-0.010178559d,-0.019609304d,0.004112968d,-0.011217186d,-0.031574301d,-0.008766023d,0.005483958d,-0.061819162d,-0.023431456d,-0.040714234d,0.015039339d,0.026422706d,0.016202603d,0.004653055d,0.041046593d,-0.018030589d,0.040381871d,-0.002638116d,0.013045172d,0.004216831d,0.005650138d,0.027419789d,0.003926015d,-0.028749233d,0.004798463d,-0.030244859d,0.063813329d,0.007145763d,-0.017448956d,0.025591804d,-0.045201108d,0.010718645d,0.002804297d,0.014291527d,0.04586583d,-0.015205519d,-0.021603471d,-0.035230275d,0.00760276d,0.033236109d,0.016534964d,-0.043206941d,-0.003115885d,-0.026256526d,0.005940954d,0.016534964d,0.024262359d,-0.001630647d,0.028084511d,-0.012795902d,0.007270399d,0.001381376d,-0.009763107d,-0.006896493d,0.008433662d,-0.019360034d,0.000386889d,0.030411039d,0.025591804d,0.010469374d,0.037722982d,-0.001147684d,-0.005400868d,0.052845411d,-0.052513052d,0.00768585d,-0.004299921d,0.00922302d,0.011881908d,0.012962082d,-0.068798743d,0.003593654d,0.020938748d,-0.013792985d,-0.034565553d,-0.007519669d,-0.04021569d,-0.020689478d,0.006273315d,0.046862911d,0.006107135d,0.002638116d,-0.013792985d,-0.005400868d,-0.020274026d,0.007644305d,-0.010801735d,0.026422706d,0.043871664d,0.003780607d,0.010261648d,-0.064145692d,0.011881908d,-0.009056839d,0.009347656d,-0.02459472d,0.026422706d,0.033236109d,0.041212775d,0.019027673d,-0.00315743d,0.004424557d,0.020689478d,-0.0153717d,-0.015205519d,-0.034897912d,0.020274026d,0.016867325d,0.040714234d,-0.022766734d,-0.010967916d,0.026256526d,0.007062673d,-0.015953332d,-0.007727395d,0.031574301d,-0.002887387d,-0.00614868d,0.004569965d,0.019027673d,0.012878992d,0.011798819d,0.004258377d,-0.019193852d,-0.021437289d,-0.021603471d,0.000301202d,-0.051183607d,-0.004985416d,-0.030078677d,0.012629721d,0.065142773d,-0.031740483d,-0.021104928d,-0.03938479d,-0.003365156d,-0.016036423d,0.036393538d,0.009804652d,-0.018612221d,0.060489718d,-0.003697517d,0.000547876d,0.063480966d,0.02758597d,0.010053922d,-0.003655972d,-0.001485239d,0.018362951d,0.021104928d,-0.003905243d,0.019443123d,-0.002658889d,-0.00380138d,-0.013626805d,0.035894997d,0.035396457d,-0.005691683d,0.002762751d,0.012878992d,-0.009596926d,-0.009970833d,-0.015953332d,0.022434372d,0.00614868d,-0.021188019d,0.001557943d,-0.020190936d,0.009763107d,0.017448956d,0.006730312d,0.005567048d,0.019692395d,-0.00218112d,-0.016867325d,0.006854947d,0.007976666d,0.019193852d,0.040880412d,0.007353489d,-0.02127111d,-0.031906664d,-0.026755067d,-0.017947499d,0.040381871d,0.042209856d,0.00913993d,-0.0307434d,-0.017781317d,-0.015039339d,0.03057722d,0.017532047d,0.0187784d,-0.060822077d,0.002928932d,-0.026422706d,-0.005899409d,0.039717149d,0.026588887d,-0.000971118d,0.004923099d,-0.013626805d,0.0187784d,-0.031408124d,-0.000695881d,0.050851244d,-0.014457707d,-0.007311944d,-0.001293092d,-0.002139574d,-0.019276943d,0.00290816d,0.019360034d,-0.017781317d,0.002160347d,0.016618054d,-0.006522586d,0.011798819d,0.029247776d,-0.02775215d,0.010344739d,-0.018362951d,-0.036725901d,-0.015870241d,0.015704062d,-0.012463541d,0.02459472d,-0.024096178d,0.001152877d,-0.031408124d,0.025425622d,0.027087428d,0.00922302d,0.034565553d,0.015704062d,-0.020689478d,-0.00517237d,-0.014706978d,-0.001589101d,0.026090344d,0.014956249d,0.011715728d,0.004299921d,-0.00913993d,0.022434372d,-0.03705826d,0.048524719d,-0.030411039d,0.008433662d,0.017033506d,-0.000511525d,-0.031408124d,0.005940954d,-0.012962082d,-0.031574301d,0.017448956d,0.010178559d,-0.011383367d,-0.020107845d,-0.005151597d,0.006647222d,0.013128263d,0.007145763d,0.008059756d,-0.045201108d,-0.004943871d,0.015787151d,-0.045201108d,-0.020772567d,-0.020274026d,0.028250692d,-0.024262359d,-0.004424557d,0.009804652d,0.000472576d,-0.005691683d,0.001443693d,-0.013294443d,0.001412535d,0.013211353d,-0.01213118d,-0.002118802d,0.017781317d,-0.007353489d,-0.031075761d,-0.004923099d,0.011383367d,-0.004486875d,-0.010178559d,0.016618054d,0.014457707d,0.023763817d,-0.02459472d,-0.00388447d,0.012546631d,-0.007519669d,0.015704062d,-0.014291527d,0.009680017d,-0.035562634d,0.023763817d,0.053510133d,-0.0555043d,-0.003572882d,0.022102011d,0.021603471d,-0.017282777d,-0.001474852d,-0.043539301d,0.007810486d,-0.025757983d,-0.005400868d,0.029912498d,-0.00760276d,0.014125346d,0.030909581d,-0.03340229d,-0.009680017d,0.018030589d,0.008849114d,0.03057722d,0.019775484d,0.014125346d,0.031906664d,-0.03057722d,-0.027087428d,-0.023597637d,-0.022434372d,-0.012878992d,0.016285693d,-0.021603471d,-0.029746316d,0.029746316d,0.020357117d,0.006314861d,-0.001158071d,0.028749233d,-0.045201108d,0.011383367d,0.011134096d,-0.021437289d,-0.035728816d,0.001827986d,0.008267482d,-0.057498466d,0.01213118d,-0.01213118d,-0.040548053d,0.010718645d,0.004798463d,-0.004881553d,-0.019526213d,-0.008558298d,0.0059825d,-0.000262254d,-0.017615138d,0.005193142d,0.019692395d,-0.00198378d,-0.002845842d,0.012546631d,0.006107135d,-0.008225936d,-0.008890659d,0.015870241d,0.00517237d,0.002596571d,-0.010427829d,-0.019110762d,0.024262359d,0.012048089d,-0.032405205d,0.006522586d,0.013211353d,0.013211353d,-0.038221523d,-0.007727395d,-0.008267482d,-0.019276943d,0.001474852d,0.031408124d,-0.035562634d,0.017532047d,-0.023431456d,-0.015454791d,-0.011383367d,0.016534964d,-0.02176965d,0.008682934d,0.027253609d,0.020190936d,-0.0247609d,-0.007311944d,0.009555381d,-0.01852913d,-0.011632638d,0.011549547d,0.027419789d,-0.034067012d,-0.01229736d,0.0307434d,0.003946788d,0.0046946d,0.037722982d,0.03057722d,-0.010427829d,0.002284982d,0.033236109d,0.030078677d,-0.013377533d,0.007395034d,-0.012048089d,0.040714234d,-0.028749233d,-0.000102565d,-0.0059825d,-0.041046593d,0.017698228d,-0.006356406d,0.003178203d,0.009056839d,0.023099095d,0.00606559d,0.011881908d,-0.02127111d,-0.001126912d,-0.027087428d,0.011134096d,0.001204809d,-0.017033506d,0.011051006d,-0.014374617d,0.017864408d,0.023431456d,-0.002077257d,-0.026755067d,-0.043871664d,0.025757983d,-0.006190225d,0.001152877d,0.011798819d,-0.024262359d,0.006564131d,-0.070128188d,-0.004362239d,0.012962082d,-0.013626805d,-0.001402148d,-0.012214269d,0.011217186d,-0.015953332d,0.015787151d,0.011134096d,0.027253609d,0.024262359d,-0.048192356d,0.009970833d,0.018944582d,-0.00517237d,0.021935832d,0.02775215d,0.003406701d,-0.010884825d,0.075113602d,-0.015953332d,0.007727395d,0.026755067d,-0.006190225d,-0.012712811d,0.013377533d,0.005940954d,-0.008309027d,0.02459472d,0.002316141d,-0.022434372d,-0.012712811d,0.03057722d,-0.015787151d,0.026755067d,-0.001069787d,0.03988333d,-0.003697517d,0.039550968d,-0.019027673d,-0.0059825d,-0.00031029d,-0.012546631d,-0.003614427d,0.007478124d,0.005525503d,0.032571387d,-0.011798819d,-0.011466458d,-0.00606559d,-0.011798819d,0.018446039d,0.007976666d,0.018944582d,-0.02176965d,0.026588887d,-0.006273315d,-0.012463541d,-0.007395034d,0.012048089d,-0.029247776d,0.015454791d,-0.007145763d,0.006481041d,-0.015620971d,-0.00388447d,-0.025757983d,-0.001651419d,-0.032903746d,-0.005068507d,0.03938479d,0.003926015d,0.004715373d,0.022600554d,-0.012546631d,0.022932915d,0.007810486d,0.040714234d,0.019941665d,0.013543714d,0.003406701d,0.010884825d,-0.03988333d,0.042209856d,-0.022766734d,0.027419789d,-0.029580137d,0.043206941d,0.022932915d,0.021104928d,-0.056833744d,0.005193142d,0.036061179d,-0.012878992d,0.008516753d,-0.02758597d,-0.030244859d,-0.011798819d,0.001111332d,-0.014125346d,-0.014125346d,0.019027673d,0.029081594d,0.018861491d,0.013626805d,0.06846638d,0.023099095d,0.041378956d,0.001599488d,-0.028749233d,0.017781317d,0.016285693d,0.021603471d,-0.018113678d,0.011300277d,-0.032239024d,0.022434372d,-0.02459472d,-0.013626805d,0.005483958d,0.013460624d,-0.031574301d,-0.015620971d,0.016451873d,0.014790068d,-0.008849114d,0.011134096d,0.00461151d,0.015122429d,0.036227357d,0.00206687d,0.000877641d,0.022102011d,-0.028250692d,0.022600554d,-0.026422706d,0.004029878d,-0.032072846d,0.017116595d,0.010884825d,0.019609304d,0.00614868d,0.005733229d,0.016119512d,0.002866614d,-0.014540797d,0.012463541d,-0.003905243d,0.003759835d,-0.000485559d,-0.022766734d,-0.016285693d,0.037722982d,0.009513836d,0.001506011d,0.011964999d,0.004029878d,0.019941665d,-0.000965924d,0.002129188d,0.015205519d,0.071125269d,0.022932915d,0.005940954d,-0.00044661d,0.010220103d,-0.03423319d,-0.016285693d,-0.016867325d,-0.000659529d,-0.008018211d,-0.011383367d,0.000016634d,0.004071423d,-0.029413955d,0.019941665d,-0.00913993d,-0.024096178d,0.010635555d,0.010594009d,0.001547556d,0.036227357d,-0.030078677d,0.020772567d,0.022268193d,-0.014125346d,0.008766023d,-0.012962082d,-0.007187308d,0.017033506d,-0.007187308d,-0.015205519d,-0.005608593d,0.044536386d,-0.001235968d,0.007852031d,0.001599488d,0.005857864d,-0.005940954d,-0.010510919d,-0.005567048d,0.006730312d,0.016285693d,-0.010801735d,-0.024428539d,0.015122429d,-0.02176965d,0.01528861d,-0.007436579d,0.00226421d,-0.004715373d,0.004507647d,0.004341467d,0.005525503d,-0.031075761d,-0.005899409d,0.037556801d,0.014873158d,-0.000342747d,0.009970833d,-0.019443123d,0.023597637d,-0.012048089d,-0.025259443d,0.006024044d,-0.01827986d,0.010012378d,0.016784234d,0.013211353d,-0.005400868d,-0.024428539d,-0.02176965d,-0.035230275d,0.009347656d,0.028583053d,-0.015704062d,-0.017781317d,0.00226421d,0.001199616d,-0.003385928d,0.008267482d,0.002326528d,0.022434372d,-0.020190936d,-0.015787151d,0.000789358d,0.031241942d,0.011300277d,0.001506011d,-0.023265276d,-0.010967916d,0.009056839d,0.011300277d,-0.030244859d,0.007478124d,0.001111332d,-0.035894997d,0.0153717d,0.002700434d,0.021104928d,0.010884825d,-0.003344383d,0.00768585d,0.010386284d,0.00452842d,-0.014706978d,0.028084511d,0.013377533d,0.014873158d,0.046862911d,-0.015454791d,0.021188019d,0.013959166d,0.012629721d,0.025924165d,-0.018695312d,-0.00922302d,-0.0093892d,0.007727395d,0.036892079d,0.007228854d,-0.01229736d,0.029247776d,-0.004943871d,-0.027253609d,-0.008433662d,0.043206941d,0.002825069d,0.028583053d,-0.023431456d,0.034897912d,-0.041545134d,-0.016534964d,0.003053567d,-0.012712811d,0.002741979d,-0.007187308d,-0.025093261d,-0.045201108d,-0.004424557d,-0.016618054d,-0.008890659d,0.008018211d,-0.05184833d,-0.019526213d,-0.013377533d,-0.010469374d,0.030244859d,-0.005068507d,0.051183607d,0.005483958d,-0.006024044d,0.035064094d,-0.011134096d,0.014956249d,0.002284982d,0.001724123d,-0.01229736d,0.012629721d,0.010261648d,0.014540797d,0.048857078d,-0.029580137d,-0.024927082d,-0.008350573d,-0.03988333d,0.000939959d,0.013543714d,0.013626805d,-0.021437289d,-0.012962082d,0.006771857d,0.013709894d,-0.0059825d,0.035396457d,-0.006439496d,-0.029580137d,0.0046946d,0.019609304d,-0.007270399d,0.014291527d,-0.015620971d,0.00118923d,-0.00760276d,-0.017199686d,0.023265276d,0.026588887d,-0.030078677d,-0.016701145d,-0.025757983d,0.004964644d,0.026588887d,0.043206941d,0.011051006d,-0.009846197d,0.028915415d,0.031574301d,0.023763817d,0.009264565d,-0.008433662d,-0.035064094d,-0.000579035d,-0.0247609d,0.014125346d,0.016618054d,0.028749233d,-0.052513052d,-0.016867325d,-0.01238045d,0.002741979d,0.013709894d,0.010718645d,0.013626805d,0.009596926d,-0.004403784d,-0.02758597d,-0.000945152d,0.000420645d,0.003759835d,0.012546631d,-0.011881908d,0.008392117d,0.012795902d,0.005483958d,-0.009763107d,0.006397951d,-0.010801735d,0.012795902d,-0.03938479d,0.005733229d,0.005733229d,-0.000433627d,0.015454791d,0.002357686d,-0.006564131d,0.030244859d,-0.024428539d,0.016036423d,0.014291527d,-0.004964644d,0.029413955d,0.040381871d,0.012629721d,-0.033568468d,-0.026422706d,-0.037889164d,-0.034399372d,-0.03423319d,0.021935832d,0.004133741d,-0.014623888d,-0.013543714d,-0.05517194d,0.004736145d,0.006314861d,0.00006037d,0.006356406d,0.003323611d,-0.010344739d,0.007062673d,0.005899409d,-0.00623177d,-0.001973394d,-0.0555043d,0.011881908d,0.001350217d,-0.033069927d,-0.026921248d,0.022268193d,0.028583053d,-0.021021837d,0.010884825d,0.019692395d,-0.005442413d,0.031574301d,-0.014956249d,0.01238045d,-0.006356406d,0.006273315d,-0.003095113d,-0.014540797d,-0.02176965d,0.005006189d,-0.002658889d,0.042542219d,-0.02176965d,0.017199686d,-0.016701145d,-0.001599488d,0.016950415d,-0.021188019d,0.017864408d,0.023763817d,-0.000669915d,0.025093261d,0.021104928d,0.008807569d,0.037390623d,-0.025591804d,-0.003178203d,-0.001319058d,0.020523297d,0.005255459d,0.019276943d,-0.00226421d,0.00760276d,-0.057166107d,-0.006896493d,-0.034067012d,0.043871664d,0.038221523d,0.008101301d,0.03988333d,0.015870241d,0.000955538d,-0.004299921d,-0.002928932d,-0.002118802d,-0.020523297d,-0.001168457d,-0.011134096d,-0.000685495d,0.003323611d,0.011549547d,0.034565553d,0.029247776d,-0.029746316d,0.005213914d,0.019110762d,-0.003302838d,0.026422706d,0.028915415d,-0.036227357d,0.033236109d,0.038387705d,-0.035230275d,0.004071423d,-0.021935832d,0.002928932d,0.000976311d,0.000527104d,-0.006854947d,-0.003822153d,-0.001199616d,0.019858574d,-0.002762751d,0.039052427d,-0.008641388d,0.032239024d,-0.002295369d,0.035396457d,0.044536386d,-0.029413955d,0.025093261d,-0.03423319d,-0.016867325d,-0.008849114d,0.008433662d,-0.004486875d,0.017033506d,0.006730312d,-0.008599843d,-0.008225936d,-0.024428539d,0.006564131d,-0.007561215d,-0.032072846d,-0.019941665d,0.035396457d,0.019276943d,0.010261648d,0.005857864d,0.032239024d,-0.044204023d,-0.018944582d,0.002409618d,0.032903746d,0.05517194d,-0.03655972d,0.007976666d,0.030909581d,-0.023929998d,0.016368784d,0.01528861d,-0.00768585d,0.02176965d,0.013626805d,-0.02459472d,0.04021569d,-0.032737568d,0.006854947d,-0.011383367d,0.014873158d,-0.02176965d,0.00243039d,0.0093892d,0.0093892d,-0.029580137d,0.019858574d,0.01827986d,0.024428539d,0.017864408d,-0.028250692d,-0.001111332d,0.056169022d,0.007478124d,-0.010718645d,0.041046593d,-0.015704062d,0.034731735d,0.002523867d,-0.032571387d,0.004341467d,-0.023597637d,-0.011881908d,-0.035562634d,0.006688767d,0.007810486d,-0.012712811d,0.022600554d,0.03057722d,0.022600554d,0.010552464d,0.0307434d,-0.009638472d,0.02176965d,-0.018030589d,0.024262359d,-0.036227357d,-0.020772567d,0.001641033d,-0.022932915d,-0.014623888d,0.018362951d,0.002575798d,0.006190225d,-0.011051006d,0.021021837d,0.019110762d,0.02127111d,-0.028583053d,-0.052180689d,-0.014291527d,-0.010552464d,0.036393538d,0.042542219d,-0.04586583d,-0.001869531d,0.008350573d,-0.008516753d,-0.020772567d,0.000294711d,0.015704062d,-0.014457707d,-0.020772567d,0.008766023d,-0.026588887d,-0.004736145d,-0.028084511d,-0.007519669d,0.010552464d,-0.016534964d,0.006190225d,0.012962082d,-0.016618054d,0.012546631d,0.02459472d,0.022932915d,0.020440206d,-0.027918331d,-0.008059756d,0.020689478d,-0.014623888d,-0.011466458d,-0.006896493d,-0.020024756d,-0.031408124d,0.021603471d,0.007270399d,-0.03057722d,0.008350573d,-0.021437289d,0.00072704d,-0.043871664d,0.006314861d,-0.017199686d,0.02176965d,0.024262359d,-0.020357117d,-0.000542683d,-0.005213914d,0.001963008d,-0.00064395d,-0.022434372d,0.022102011d,-0.006688767d,-0.028583053d,0.002191506d,-0.005047734d,0.002368073d,0.014956249d,0.023929998d,-0.003302838d,-0.032239024d,0.022268193d,-0.013377533d,-0.010801735d,0.003676744d,0.009015295d,-0.039550968d,0.010884825d,-0.033568468d,0.013709894d,-0.029413955d,-0.006356406d,-0.020274026d,0.023597637d,0.030909581d,0.02176965d,0.016285693d,0.045533467d,-0.024096178d,-0.030909581d,-0.026422706d,0.002783524d,-0.010594009d,0.004362239d,-0.070792913d,0.009472291d,-0.022102011d,0.011134096d,-0.017448956d,-0.011549547d,-0.056833744d,0.00082571d,0.026588887d,-0.013709894d,0.002575798d,0.02176965d,-0.000568649d,-0.007270399d,0.004279149d,-0.042874578d,-0.026588887d,0.016784234d,0.036725901d,-0.028915415d,-0.009513836d,0.017448956d,0.002035712d,-0.007228854d,0.011383367d,0.011134096d,0.028915415d,0.0153717d,-0.027087428d,0.043871664d,-0.005089279d,0.006314861d,0.014291527d,-0.003240521d,0.025924165d,-0.001230775d,-0.015454791d,-0.012629721d,0.031740483d,-0.039717149d,-0.031075761d,0.006605676d,-0.008641388d,-0.032239024d,0.037722982d,-0.03705826d,-0.024096178d,0.001911076d,0.018196769d,-0.007353489d,-0.011300277d,-0.029081594d,0.004590738d,-0.018030589d,-0.026588887d,0.010261648d,0.038221523d,0.008392117d,-0.01213118d,0.018362951d,-0.034731735d,-0.017781317d,-0.011632638d,0.005255459d,0.000851675d,0.014208436d,-0.000039922d,-0.000228498d,0.014790068d,0.00913993d,0.0004544d,-0.011798819d,-0.020440206d,0.005899409d,0.008350573d,0.006314861d,0.040548053d,0.003427474d,-0.010801735d,0.008599843d,0.002586185d,-0.041212775d,-0.016368784d,0.020024756d,0.000965924d,-0.021021837d,-0.008475208d,0.0307434d,0.00760276d,0.003614427d,0.003489791d,-0.025924165d,0.000799744d,0.013460624d,-0.020440206d,0.048857078d,0.004320694d,-0.048857078d,0.015039339d,-0.029580137d,0.025924165d,0.018861491d,-0.014706978d,0.000576439d,-0.031241942d,0.0307434d,0.0153717d,0.014706978d,0.028084511d,-0.01238045d,-0.031241942d,0.018196769d,-0.034897912d,0.008142847d,0.010718645d,0.00922302d,0.047859997d,-0.00072704d,-0.010427829d,0.007104218d,0.026256526d,0.012214269d,-0.013377533d,-0.05184833d,0.005276232d,0.021935832d,-0.007021128d,0.009804652d,0.007893575d,0.024096178d,-0.002357686d,0.033900831d,-0.031740483d,0.034565553d,-0.036892079d,-0.015454791d,0.030411039d,0.010552464d,-0.022268193d,-0.001391762d,-0.008184392d,-0.008558298d,0.008475208d,-0.009929287d,0.010427829d,0.041378956d,-0.009555381d,-0.008724478d,-0.039052427d,0.034731735d,-0.014291527d,0.023099095d,0.029081594d,0.007519669d,0.010967916d,-0.008142847d,0.006190225d,-0.031075761d,0.033734649d,-0.001672192d,0.047859997d,-0.022434372d,-0.007395034d,0.01213118d,0.056169022d,0.002762751d,-0.029413955d,-0.000763392d,-0.015787151d,0.010801735d,0.008142847d,0.029912498d,-0.0018176d,0.033236109d,-0.046198189d,-0.002492708d,-0.006730312d,0.008807569d,-0.03655972d,0.009430746d,-0.053842496d,-0.060489718d,0.046862911d,0.002783524d,-0.0187784d,0.000571246d,0.00760276d,0.002482322d,0.001319058d,-0.014291527d,0.001464466d,-0.011632638d,-0.012463541d,-0.004902326d,0.000841289d,0.006688767d,0.030244859d,0.018944582d,0.000532297d,-0.015620971d,0.007104218d,0.005608593d,0.002035712d,-0.023763817d,0.003032795d,0.010594009d,-0.023597637d,-0.042376038d,-0.005255459d,0.001199616d,-0.0247609d,-0.007893575d,-0.011632638d,0.013045172d,-0.005691683d,-0.007104218d,0.027419789d,-0.004320694d,-0.005525503d,-0.026090344d,0.031408124d,-0.012795902d,-0.007062673d,0.000939959d,0.000030185d,0.004175286d,0.014291527d,0.033236109d,-0.038720068d,0.074116521d,-0.019692395d,0.001589101d,0.013792985d,-0.056169022d,-0.028749233d,-0.001599488d,0.004175286d,0.014790068d,0.00162026d,-0.007519669d,-0.041378956d,0.016534964d,-0.003572882d,-0.002575798d,-0.019526213d,-0.00922302d,-0.033900831d,-0.042043675d,-0.014208436d,0.010178559d,0.017698228d,0.032239024d,0.00913993d,0.009264565d,-0.012463541d,-0.005857864d,-0.015870241d,0.004486875d,0.018861491d,-0.000176567d,-0.029912498d,0.016784234d,0.012546631d,0.051183607d,0.023597637d,0.032903746d,0.0153717d,-0.013377533d,-0.000016634d,-0.061486799d,-0.034565553d,0.016119512d,0.00380138d,-0.003863698d,0.004362239d,-0.017532047d,-0.002762751d,0.000102565d,-0.021437289d,0.029247776d,-0.010718645d,-0.015870241d,-0.016285693d,0.010220103d,-0.000373906d,0.012962082d,0.010137013d,-0.007228854d,0.02127111d,-0.029247776d,0.018113678d,0.009181475d,0.002233051d,0.014374617d,-0.00396756d,0.010801735d,0.007644305d,0.020855658d,0.014790068d,0.032737568d,-0.037390623d,0.003032795d,0.010801735d,-0.01553788d,-0.014790068d,0.019526213d,-0.017947499d,-0.007893575d,-0.011964999d,-0.00614868d,-0.005857864d,-0.032072846d,-0.025924165d,0.001163264d,-0.013294443d,-0.01553788d,0.016701145d,-0.013460624d,-0.001111332d,0.00760276d,0.01553788d,-0.033734649d,0.048192356d,-0.003282066d,0.031906664d,0.002845842d,0.003240521d,0.017116595d,-0.01827986d,0.006896493d,-0.00760276d,-0.009680017d,-0.02459472d,-0.020689478d,-0.053510133d,0.00614868d,-0.010552464d,-0.032405205d,-0.0307434d,0.025093261d,0.003635199d,-0.008101301d,-0.00606559d,-0.007436579d,0.00606559d,-0.012962082d,0.026921248d,0.009098385d,0.046530552d,-0.011632638d,0.032571387d,-0.033900831d,0.009846197d,0.002866614d,0.032903746d,0.008973749d,0.012712811d,0.040049512d,0.013626805d,-0.026256526d,-0.031408124d,0.036227357d,0.011964999d,-0.006024044d,-0.001848759d,0.015704062d,-0.021188019d,-0.035064094d,-0.013377533d,-0.009721561d,-0.01553788d,0.008766023d,0.005400868d,0.004507647d,-0.018362951d,-0.026588887d,-0.00913993d,-0.025591804d,0.035894997d,0.021935832d,-0.031906664d,-0.000602404d,0.026422706d,-0.006397951d,0.006647222d,0.0093892d,0.020606387d,0.00913993d,0.015620971d,-0.024096178d,0.00063616d,-0.006564131d,0.01238045d,-0.013709894d,0.000563456d,-0.009887742d,0.016618054d,-0.003323611d,0.000451803d,0.001609874d,0.008682934d,0.025259443d,0.020024756d,-0.027253609d,0.010884825d,0.028250692d,-0.054839578d,0.033568468d,-0.004902326d,0.003053567d,0.020274026d,-0.015704062d,-0.00614868d,-0.063813329d,0.002482322d,0.009763107d,-0.001609874d,-0.012214269d,0.020107845d,0.001921462d,0.018695312d,-0.004923099d,0.007270399d,-0.023763817d,0.005234687d,0.003406701d,0.002565412d,0.007104218d,0.000841289d,0.016202603d,0.01827986d,-0.031075761d,-0.035562634d,-0.025259443d,-0.007021128d,0.000641353d,-0.033069927d,0.010718645d,0.005650138d,0.024927082d,-0.002658889d,0.00380138d,0.009929287d,-0.004258377d,-0.039717149d,-0.022434372d,0.025425622d,0.00198378d,0.006356406d,0.017615138d,-0.032072846d,0.046862911d,-0.026921248d,0.005940954d,0.021603471d,-0.002253824d,0.002825069d,-0.030411039d,-0.003115885d,0.023597637d,-0.004320694d,-0.007852031d,0.018030589d,-0.008724478d,-0.005733229d,0.032903746d,0.013876075d,0.015454791d,-0.023597637d,0.005151597d,-0.035396457d,0.02176965d,-0.012463541d,0.025591804d,0.014540797d,-0.027918331d,0.004154514d,0.008724478d,0.016036423d,-0.015870241d,0.005400868d,-0.017365867d,-0.044868745d,-0.000485559d,0.020357117d,-0.00760276d,-0.023265276d,-0.012048089d,0.008433662d,0.018362951d,-0.006979583d,0.0307434d,0.008392117d,0.027087428d,-0.019360034d,0.016119512d,0.02127111d,0.010801735d,0.00299125d,0.002949705d,0.012463541d,-0.000025966d,0.015953332d,0.029413955d,0.020024756d,0.003780607d,0.022102011d,-0.031740483d,0.01553788d,0.010386284d,0.028749233d,-0.010884825d,0.008682934d,-0.003531337d,-0.05517194d,-0.019360034d,-0.009347656d,-0.002025325d,0.003261293d,-0.025425622d,-0.01553788d,-0.000251867d,0.014291527d,0.012546631d,0.035728816d,-0.007062673d,-0.006605676d,0.000384293d,-0.005047734d,-0.032571387d,-0.021188019d,-0.02127111d,-0.016036423d,0.008475208d,-0.004009106d,0.014291527d,-0.008101301d,0.004424557d,-0.038221523d,-0.019360034d,0.015039339d,-0.015454791d,-0.029580137d,0.035728816d,0.004466102d,-0.000778971d,-0.005068507d,-0.017781317d,0.00477769d,0.001838372d,0.030244859d,0.01213118d,-0.022932915d,-0.005359322d,0.037390623d,0.005899409d,0.002046098d,0.037889164d,0.016701145d,0.010303194d,0.02127111d,-0.009513836d,-0.022268193d,-0.005650138d,-0.00388447d,0.016534964d,-0.023265276d,-0.00054528d,0.004819236d,0.004715373d,-0.001178843d,-0.051183607d,-0.00614868d,-0.010552464d,-0.002741979d,-0.009181475d,0.023597637d,0.019193852d,0.017199686d,-0.036393538d,-0.00243039d,-0.015870241d,-0.014706978d,-0.00145408d,0.016368784d,-0.011632638d,-0.014623888d,-0.01229736d,-0.01553788d,0.040880412d,0.023929998d,-0.014623888d,0.002648502d,0.031906664d,-0.033734649d,-0.026755067d,0.002783524d,0.005359322d,0.009970833d,0.001412535d,0.016950415d,0.016285693d,-0.006730312d,-0.02459472d,0.050851244d,-0.001827986d,-0.020855658d,0.020938748d,0.004071423d,-0.021603471d,-0.007852031d,-0.023929998d,-0.029912498d,-0.003365156d,0.017365867d,-0.010427829d,-0.011715728d,0.014956249d,0.011383367d,0.032405205d,-0.028583053d,-0.017448956d,0.018446039d,0.017615138d,0.035728816d,-0.010095468d,-0.00254464d,0.010012378d,0.028250692d,-0.020855658d,-0.002305755d,-0.001002276d,-0.014125346d,-0.007021128d,-0.028583053d,-0.045533467d,-0.02758597d,-0.020440206d,0.001350217d,0.010053922d,0.020689478d,-0.017615138d,0.026422706d,0.040880412d,0.012463541d,-0.010718645d,-0.014706978d,0.068134025d,0.038720068d,0.047859997d,-0.012546631d,0.015704062d,-0.002087643d,-0.010303194d,0.014790068d,0.018612221d,0.007395034d,-0.014790068d,-0.017864408d,-0.005068507d,-0.054507218d,0.004902326d,-0.004050651d,0.021603471d,0.019775484d,-0.024262359d,-0.012795902d,0.021935832d,-0.004009106d,-0.039717149d,0.037556801d,-0.016701145d,-0.025757983d,0.005483958d,-0.005110051d,-0.021935832d,-0.003406701d,0.010594009d,0.015787151d,-0.049854163d,0.007727395d,-0.008392117d,-0.017199686d,0.009970833d,-0.008849114d,-0.013876075d,-0.0059825d,-0.015870241d,-0.007104218d,0.028250692d,-0.029081594d,0.026921248d,0.00299125d,-0.017781317d,0.042542219d,0.018196769d,0.052845411d,-0.004819236d,-0.014125346d,0.02459472d,-0.011715728d,0.015787151d,-0.005774774d,0.004902326d,-0.004964644d,-0.02758597d,-0.013959166d,-0.033568468d,-0.027918331d,-0.017698228d,0.003489791d,-0.020024756d,-0.021603471d,0.019360034d,0.028084511d,-0.002503094d,-0.018861491d,-0.002295369d,0.050851244d,-0.020689478d,-0.000459593d,-0.026090344d,0.002783524d,-0.005899409d,-0.026921248d,-0.0093892d,-0.004112968d,0.031574301d,0.003926015d,-0.032903746d,-0.046198189d,-0.019027673d,-0.00913993d,0.030411039d,-0.019443123d,0.001963008d,-0.005193142d,0.010884825d,-0.02127111d,-0.025259443d,0.032737568d,0.00089322d,0.003282066d,0.001713737d,-0.006439496d,0.016867325d,-0.031574301d,0.031075761d,-0.009970833d,0.022600554d,-0.023597637d,-0.014956249d,0.004009106d,0.00198378d,0.026588887d,-0.023431456d,-0.023763817d,-0.013294443d,-0.029746316d,0.001381376d,-0.042874578d,-0.00913993d,0.014873158d,0.016202603d,0.012878992d,-0.006024044d,0.009638472d,0.010552464d,-0.017033506d,-0.027087428d,0.044536386d,-0.038055345d,0.001329444d,-0.019609304d,0.023597637d,-0.043206941d,0.040049512d,0.017615138d,0.046862911d,0.02127111d,0.013294443d,-0.039550968d,-0.018861491d,-0.019609304d,-0.033734649d,0.00623177d,-0.017199686d,0.041212775d,-0.017781317d,-0.024262359d,0.054507218d,-0.009721561d,0.005816319d,-0.00206687d,-0.008766023d,0.017365867d,-0.000737426d,0.018362951d,-0.023597637d,-0.019110762d,0.021935832d,0.041545134d,-0.020357117d,-0.017615138d,0.044868745d,-0.018030589d,-0.032405205d,-0.050186522d,-0.014540797d,0.005213914d,-0.006688767d,0.047527634d,0.040714234d));
    34 String indexName = "vector_index";
    35 FieldSearchPath fieldSearchPath = fieldPath("plot_embedding_voyage_3_large");
    36 int limit = 10;
    37 int numCandidates = 150;
    38
    39 // define pipeline
    40 List<Bson> pipeline = asList(
    41 vectorSearch(
    42 fieldSearchPath,
    43 queryVector,
    44 indexName,
    45 limit,
    46 approximateVectorSearchOptions(numCandidates)),
    47 project(
    48 fields(exclude("_id"), include("title"), include("plot"),
    49 metaVectorSearchScore("score"))));
    50
    51 // run query and print results
    52 collection.aggregate(pipeline)
    53 .forEach(doc -> System.out.println(doc.toJson()));
    54 }
    55 }
    56}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Compile and run the BasicQuery.java file:

javac BasicQuery.java
java BasicQuery
1{"plot": "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title": "About Time", "score": 0.7710106372833252}
2{"plot": "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title": "Retroactive", "score": 0.760047972202301}
3{"plot": "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title": "A.P.E.X.", "score": 0.7576861381530762}
4{"plot": "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title": "Timecop", "score": 0.7576561570167542}
5{"plot": "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title": "Back to the Future Part II", "score": 0.7521393895149231}
6{"plot": "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title": "Thrill Seekers", "score": 0.7509932518005371}
7{"plot": "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title": "Timerider: The Adventure of Lyle Swann", "score": 0.7502642869949341}
8{"plot": "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title": "The Time Machine", "score": 0.7502503395080566}
9{"plot": "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title": "The Time Traveler's Wife", "score": 0.749496340751648}
10{"plot": "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title": "The Final Countdown", "score": 0.7469133734703064}
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlasVectorSearchQuery.kt.

  2. Copy and paste the following sample query into the atlasVectorSearchQuery.kt file:

    1import com.mongodb.client.model.Aggregates
    2import com.mongodb.client.model.Projections
    3import com.mongodb.client.model.search.SearchPath.fieldPath
    4import com.mongodb.client.model.search.VectorSearchOptions
    5import com.mongodb.kotlin.client.coroutine.MongoClient
    6import kotlinx.coroutines.flow.count
    7import org.bson.Document
    8
    9data class Movie(val title: String, val plot: String, val score: Double?)
    10
    11suspend fun main() {
    12
    13 // Replace the placeholder with your Atlas connection string
    14 val uri = "<connection-string>"
    15 val client = MongoClient.create(uri)
    16
    17 try {
    18 // Connect to your cluster
    19 val database = client.getDatabase("sample_mflix")
    20 val collection = database.getCollection<Movie>("embedded_movies")
    21
    22 // Define the pipeline with $vectorSearch query options
    23 val queryVector = listOf(
    24 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234,
    25 )
    26 val path = fieldPath("plot_embedding_voyage_3_large")
    27 val index = "vector_index"
    28 val limit = 10L
    29 val numCandidates = 150L
    30
    31 val pipeline = listOf(
    32 Aggregates.vectorSearch(
    33 path,
    34 queryVector,
    35 index,
    36 limit,
    37 VectorSearchOptions.approximateVectorSearchOptions(numCandidates)
    38 ),
    39 Aggregates.project(
    40 Projections.fields(
    41 Projections.excludeId(),
    42 Projections.include(Movie::plot.name),
    43 Projections.include(Movie::title.name),
    44 Projections.metaVectorSearchScore(Movie::score.name)
    45 )
    46 )
    47 )
    48
    49 // Run the pipeline
    50 val resultsFlow = collection.aggregate<Document>(pipeline)
    51
    52 // Print results
    53 val resultCount = resultsFlow.count()
    54 if (resultCount > 0) {
    55 resultsFlow.collect { result ->
    56 println(result.toJson())
    57 }
    58 } else {
    59 println("No results found.")
    60 }
    61 } catch (e: Exception) {
    62 println("Error occurred: ${e.message}")
    63 } finally {
    64 client.close()
    65 }
    66}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the atlasVectorSearchQuery.kt file in your IDE. The output should resemble the following:

1{"plot": "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title": "About Time", "score": 0.7710106372833252}
2{"plot": "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title": "Retroactive", "score": 0.760047972202301}
3{"plot": "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title": "A.P.E.X.", "score": 0.7576861381530762}
4{"plot": "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title": "Timecop", "score": 0.7576561570167542}
5{"plot": "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title": "Back to the Future Part II", "score": 0.7521393895149231}
6{"plot": "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title": "Thrill Seekers", "score": 0.7509932518005371}
7{"plot": "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title": "Timerider: The Adventure of Lyle Swann", "score": 0.7502642869949341}
8{"plot": "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title": "The Time Machine", "score": 0.7502503395080566}
9{"plot": "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title": "The Time Traveler's Wife", "score": 0.749496340751648}
10{"plot": "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title": "The Final Countdown", "score": 0.7469133734703064}
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.js .

  2. Copy and paste the following sample query into the atlas-vector-search-quick-start.js file:

    1const { MongoClient } = require("mongodb");
    2
    3// connect to your cluster
    4const uri = "<connection-string>";
    5
    6const client = new MongoClient(uri);
    7
    8async function run() {
    9 try {
    10 await client.connect();
    11
    12 // set namespace
    13 const database = client.db("sample_mflix");
    14 const coll = database.collection("embedded_movies");
    15
    16 // define pipeline
    17 const agg = [
    18 {
    19 '$vectorSearch': {
    20 'index': 'vector_index',
    21 'path': 'plot_embedding_voyage_3_large',
    22 'queryVector': [
    23 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234
    24 ],
    25 'numCandidates': 150,
    26 'limit': 10
    27 }
    28 }, {
    29 '$project': {
    30 '_id': 0,
    31 'plot': 1,
    32 'title': 1,
    33 'score': {
    34 '$meta': 'vectorSearchScore'
    35 }
    36 }
    37 }
    38 ];
    39 // run pipeline
    40 const result = coll.aggregate(agg);
    41
    42 // print results
    43 await result.forEach((doc) => console.dir(JSON.stringify(doc)));
    44 } finally {
    45 await client.close();
    46 }
    47}
    48run().catch(console.dir);

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

node atlas-vector-search-quick-start.js
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.php.

  2. Copy and paste the following sample query into the atlas-vector-search-quick-start.php file:

    atlas-vector-search-quick-start.php
    1<?php
    2
    3require 'vendor/autoload.php';
    4
    5// Replace the placeholder with your Atlas connection string
    6$uri = '<connection-string>';
    7
    8try {
    9
    10 // Connect to your cluster
    11 $client = new MongoDB\Client($uri);
    12
    13 // Set the namespace
    14 $database = $client->selectDatabase('sample_mflix');
    15 $collection = $database->selectCollection('embedded_movies');
    16
    17 // Define the pipeline with $vectorSearch query options
    18 $pipeline = [
    19 [
    20 '$vectorSearch' => [
    21 'queryVector' => [
    22 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234
    23 ],
    24 'index' => 'vector_index',
    25 'path' => 'plot_embedding_voyage_3_large',
    26 'numCandidates' => 150,
    27 'limit' => 10
    28 ]
    29 ],
    30 [
    31 '$project' => [
    32 '_id' => 0,
    33 'plot' => 1,
    34 'title' => 1,
    35 'score' => [
    36 '$meta' => 'vectorSearchScore'
    37 ]
    38 ]
    39 ]
    40 ];
    41
    42 // Run the pipeline
    43 $result = $collection->aggregate($pipeline);
    44
    45 // Print results
    46 foreach ($result as $document) {
    47 echo json_encode($document) . "\n";
    48 }
    49
    50} catch (MongoDB\Driver\Exception\Exception $e) {
    51 echo "Error: " . $e->getMessage() . "\n";
    52}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

php atlas-vector-search-quick-start.php
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.py.

  2. Copy and paste the following sample query into the atlas-vector-search-quick-start.py file:

    1import pymongo
    2
    3# connect to your cluster
    4client = pymongo.MongoClient("<connection-string>")
    5
    6# define pipeline
    7pipeline = [
    8 {
    9 '$vectorSearch': {
    10 'index': 'vector_index',
    11 'path': 'plot_embedding_voyage_3_large',
    12 'queryVector': [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234],
    13 'numCandidates': 150,
    14 'limit': 10
    15 }
    16 }, {
    17 '$project': {
    18 '_id': 0,
    19 'plot': 1,
    20 'title': 1,
    21 'score': {
    22 '$meta': 'vectorSearchScore'
    23 }
    24 }
    25 }
    26]
    27
    28# run pipeline
    29result = client["sample_mflix"]["embedded_movies"].aggregate(pipeline)
    30
    31# print results
    32for i in result:
    33 print(i)
    34

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

python atlas-vector-search-quick-start.py
1{'plot': 'At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.', 'title': 'About Time', 'score': 0.7710106372833252}
2{'plot': 'A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.', 'title': 'Retroactive', 'score': 0.760047972202301}
3{'plot': 'A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...', 'title': 'A.P.E.X.', 'score': 0.7576861381530762}
4{'plot': 'An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.', 'title': 'Timecop', 'score': 0.7576561570167542}
5{'plot': 'After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.', 'title': 'Back to the Future Part II', 'score': 0.7521393895149231}
6{'plot': 'A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.', 'title': 'Thrill Seekers', 'score': 0.7509932518005371}
7{'plot': 'Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...', 'title': 'Timerider: The Adventure of Lyle Swann', 'score': 0.7502642869949341}
8{'plot': 'Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.', 'title': 'The Time Machine', 'score': 0.7502503395080566}
9{'plot': 'A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.', 'title': "The Time Traveler's Wife", 'score': 0.749496340751648}
10{'plot': 'A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.', 'title': 'The Final Countdown', 'score': 0.7469133734703064}
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas_vector_search_quick_start.rb .

  2. Copy and paste the following sample query into the atlas_vector_search_quick_start.rb file:

    1require 'mongo'
    2require 'json'
    3
    4# Replace the placeholder with your Atlas connection string
    5uri = "<connection-string>"
    6
    7begin
    8 # Connect to the MongoDB client
    9 client = Mongo::Client.new(uri, database: 'sample_mflix')
    10
    11 # Set the namespace
    12 db = client.database
    13 collection = db[:embedded_movies]
    14
    15 # Define the pipeline with $vectorSearch query options
    16 pipeline = [
    17 {
    18 '$vectorSearch' => {
    19 'queryVector' => [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234],
    20 'index' => 'vector_index',
    21 'path' => 'plot_embedding_voyage_3_large',
    22 'numCandidates' => 150,
    23 'limit' => 10
    24 }
    25 },
    26 {
    27 '$project' => {
    28 '_id' => 0,
    29 'plot' => 1,
    30 'title' => 1,
    31 'score' => { '$meta' => 'vectorSearchScore' }
    32 }
    33 }
    34 ]
    35
    36 # Run the pipeline
    37 results = collection.aggregate(pipeline)
    38
    39 # Print results
    40 results.each do |document|
    41 puts JSON(document)
    42 end
    43
    44rescue Mongo::Error::NoServerAvailable => e
    45 puts "Failed to connect to MongoDB: #{e.message}"
    46
    47rescue Mongo::Error::OperationFailure => e
    48 puts "Failed to run aggregation: #{e.message}"
    49
    50rescue Mongo::Error => e
    51 puts "A MongoDB error occurred: #{e.message}"
    52
    53rescue StandardError => e
    54 puts "A general error occurred: #{e.message}"
    55
    56ensure
    57 client&.close
    58 puts "MongoDB client closed."
    59end

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

bundle exec ruby atlas_vector_search_quick_start.rb
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

For more detailed installation instructions, see the MongoDB Rust Driver documentation.

2

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. In the /src directory of your project, create a file named vector_search_query.rs.

  2. Copy and paste the following sample query into the vector_search_query.rs file:

    vector_search_query.rs
    1use mongodb::{
    2 bson::{Document, doc},
    3 Client
    4};
    5use futures::TryStreamExt;
    6
    7#[tokio::main]
    8pub(crate) async fn basic_query() -> mongodb::error::Result<()> {
    9 // Replace the placeholder with your Atlas connection string
    10 let client = Client::with_uri_str("<connection-string>").await?;
    11
    12 let pipeline = vec! [
    13 doc! {
    14 "$vectorSearch": doc! {
    15 "queryVector": [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234],
    16 "path": "plot_embedding_voyage_3_large",
    17 "numCandidates": 150,
    18 "index": "vector_index",
    19 "limit": 10
    20 }
    21 },
    22 doc! {
    23 "$project": doc! {
    24 "_id": 0,
    25 "plot": 1,
    26 "title": 1,
    27 "score": doc! { "$meta": "vectorSearchScore"
    28 }
    29 }
    30 }
    31 ];
    32 let coll = client.database("sample_mflix").collection::<Document>("embedded_movies");
    33 let mut results = coll.aggregate(pipeline).await?;
    34 while let Some(result) = results.try_next().await? {
    35 println!("{}", result);
    36 }
    37 Ok(())
    38}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4

Since the query vector is a large inline array, add the #![recursion_limit] attribute at the top of your main.rs file. This crate-level attribute and takes effect only in the crate root, not in the vector_search_query.rs module file.

#![recursion_limit = "2560"]
mod vector_search_query;
fn main() -> mongodb::error::Result<()> {
vector_search_query::basic_query()
}
5
cargo run
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

Create a file named VectorQuery.scala. Copy and paste the following code into the file.

VectorQuery.scala
1import org.mongodb.scala._
2import org.mongodb.scala.model._
3import org.mongodb.scala.model.search.SearchPath.fieldPath
4import org.mongodb.scala.model.search.VectorSearchOptions
5
6class VectorQuery {
7 def performVectorQuery() = {
8 val collection =
9 MongoClient("<connection-string>")
10 .getDatabase("sample_mflix")
11 .getCollection("embedded_movies")
12
13 val options: VectorSearchOptions = VectorSearchOptions.approximateVectorSearchOptions(150)
14
15 collection.aggregate(Seq(
16 Aggregates.vectorSearch(fieldPath("plot_embedding_voyage_3_large"),
17 List(-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234),
18 "vector_index",
19 10,
20 options
21 ),
22 Aggregates.project(
23 Projections.fields(
24 Projections.excludeId(),
25 Projections.include("plot"),
26 Projections.include("title"),
27 Projections.meta(
28 "score", "vectorSearchScore"
29 )
30 )
31 )
32 )).foreach { doc => println(doc.toBsonDocument()) }
33 }
34}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Create a class instance and call the function in your project's Main.scala file.

object Main extends App {
private val queryInstance = new VectorQuery
queryInstance.performVectorQuery()
}
4
sbt:quick-start> ~run
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1
  1. Create a file named query-embeddings.js to store the query embeddings.

  2. Copy and paste the following embeddings for the string time travel into the query-embeddings.js file.

    QUERY_EMBEDDING = [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234];
  3. Save the query-embeddings.js file.

2

In mongosh, run the following command, replacing <path-to-file> with the complete path to your query-embeddings.js file.

load('/<path-to-file>/query-embeddings.js')

You can verify if the file loaded properly by running the following command:

QUERY_EMBEDDING.length
2048
3

Copy and paste the following sample query into your terminal and then run it using mongosh.

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

1db.embedded_movies.aggregate([
2 {
3 "$vectorSearch": {
4 "index": "vector_index",
5 "path": "plot_embedding_voyage_3_large",
6 "queryVector": QUERY_EMBEDDING,
7 "numCandidates": 150,
8 "limit": 10
9 }
10 },
11 {
12 "$project": {
13 "_id": 0,
14 "plot": 1,
15 "title": 1,
16 "score": { $meta: "vectorSearchScore" }
17 }
18 }
19])
1[
2 {
3 plot: 'At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.',
4 title: 'About Time',
5 score: 0.7710106372833252
6 },
7 {
8 plot: 'A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.',
9 title: 'Retroactive',
10 score: 0.760047972202301
11 },
12 {
13 plot: 'A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...',
14 title: 'A.P.E.X.',
15 score: 0.7576861381530762
16 },
17 {
18 plot: 'An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.',
19 title: 'Timecop',
20 score: 0.7576561570167542
21 },
22 {
23 plot: 'After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.',
24 title: 'Back to the Future Part II',
25 score: 0.7521393895149231
26 },
27 {
28 plot: 'A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.',
29 title: 'Thrill Seekers',
30 score: 0.7509932518005371
31 },
32 {
33 plot: 'Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...',
34 title: 'Timerider: The Adventure of Lyle Swann',
35 score: 0.7502642869949341
36 },
37 {
38 plot: 'Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.',
39 title: 'The Time Machine',
40 score: 0.7502503395080566
41 },
42 {
43 plot: 'A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.',
44 title: "The Time Traveler's Wife",
45 score: 0.749496340751648
46 },
47 {
48 plot: 'A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.',
49 title: 'The Final Countdown',
50 score: 0.7469133734703064
51 }
52]

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.c and copy and paste the following sample query into the file:

    atlas-vector-search-quick-start.c
    1#include <bson/bson.h>
    2#include <mongoc/mongoc.h>
    3#include <stdio.h>
    4
    5int main(void) {
    6
    7 mongoc_client_t *client;
    8 mongoc_collection_t *collection;
    9 mongoc_cursor_t *cursor;
    10 bson_array_builder_t *builder;
    11 bson_t *pipeline;
    12 bson_t query_vector;
    13 bson_error_t error;
    14 const bson_t *doc;
    15 char *str;
    16
    17 int arrSize = 2048; // This collection has a vector array of 2048 dimensions; depending on your vector embedding model, this mary vary
    18 double embeddings[] = {-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234};
    19
    20 // Initialize the MongoDB C Driver
    21 mongoc_init();
    22
    23 // Connect to your Atlas collection
    24 client = mongoc_client_new("<connection-string>");
    25 collection = mongoc_client_get_collection (client, "sample_mflix", "embedded_movies");
    26
    27 // Build query vector array
    28 builder = bson_array_builder_new();
    29
    30 for(int i = 0; i < arrSize; i++){
    31 bson_array_builder_append_double(builder, embeddings[i]);
    32 }
    33
    34 bson_array_builder_build(builder, &query_vector);
    35 bson_array_builder_destroy(builder);
    36
    37 // Create aggregation pipeline for Vector Search
    38 pipeline = BCON_NEW(
    39 "pipeline",
    40 "[",
    41 "{",
    42 "$vectorSearch", "{",
    43 "index", "vector_index",
    44 "path", "plot_embedding_voyage_3_large",
    45 "queryVector", BCON_ARRAY(&query_vector),
    46 "numCandidates", BCON_INT32(150),
    47 "limit", BCON_INT32(10),
    48 "}",
    49 "}",
    50 "{",
    51 "$project", "{",
    52 "title", BCON_BOOL(true),
    53 "plot", BCON_BOOL(true),
    54 "_id", BCON_BOOL(false),
    55 "score", "{",
    56 "$meta", "vectorSearchScore",
    57 "}",
    58 "}",
    59 "}",
    60 "]"
    61 );
    62
    63 // Run query
    64 cursor = mongoc_collection_aggregate(collection, MONGOC_QUERY_NONE, pipeline, NULL, NULL );
    65
    66 // Print results
    67 while (mongoc_cursor_next (cursor, &doc)) {
    68 str = bson_as_canonical_extended_json (doc, NULL);
    69 printf ("%s\n", str);
    70 bson_free (str);
    71 }
    72
    73 // Cleanup
    74 bson_destroy(pipeline);
    75 mongoc_cursor_destroy(cursor);
    76 mongoc_collection_destroy(collection);
    77 mongoc_client_destroy(client);
    78 mongoc_cleanup();
    79
    80 return 0;
    81}

    This query uses the $vectorSearch stage to:

    • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

    • Consider up to the 150 most similar movie plots and return the top 10 results.

    It uses the $project stage to:

    • Only include the movie plot and title fields in the results.

    • Add a score field to show the relevance of each result to the search term.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3
  1. Replace the vector_index.c file name in your CMakeLists.txt file with your new atlas-vector-search-quick-start.c filename.

  2. Navigate to the /build directory, and prepare the project.

    cd build
    cmake ../
4

From your build directory, compile and run the atlas-vector-search-quick-start.c file.

cmake --build .
./atlas-vector-search-quick-start
1{ "plot" : "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title" : "About Time", "score" : { "$numberDouble" : "0.77101063728332519531" } }
2{ "plot" : "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title" : "Retroactive", "score" : { "$numberDouble" : "0.76004797220230102539" } }
3{ "plot" : "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title" : "A.P.E.X.", "score" : { "$numberDouble" : "0.75768613815307617188" } }
4{ "plot" : "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title" : "Timecop", "score" : { "$numberDouble" : "0.75765615701675415039" } }
5{ "plot" : "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title" : "Back to the Future Part II", "score" : { "$numberDouble" : "0.7521393895149230957" } }
6{ "plot" : "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title" : "Thrill Seekers", "score" : { "$numberDouble" : "0.75099325180053710938" } }
7{ "plot" : "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title" : "Timerider: The Adventure of Lyle Swann", "score" : { "$numberDouble" : "0.75026428699493408203" } }
8{ "plot" : "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title" : "The Time Machine", "score" : { "$numberDouble" : "0.75025033950805664062" } }
9{ "plot" : "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title" : "The Time Traveler's Wife", "score" : { "$numberDouble" : "0.74949634075164794922" } }
10{ "plot" : "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title" : "The Final Countdown", "score" : { "$numberDouble" : "0.74691337347030639648" } }
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas_vector_search_quick_start.cpp .

  2. Copy and paste the following sample query into the atlas_vector_search_quick_start.cpp file:

    atlas_vector_search_quick_start.cpp
    1#include <bsoncxx/builder/basic/document.hpp>
    2#include <bsoncxx/builder/list.hpp>
    3#include <bsoncxx/json.hpp>
    4#include <mongocxx/client.hpp>
    5#include <mongocxx/instance.hpp>
    6#include <mongocxx/uri.hpp>
    7
    8using bsoncxx::builder::basic::kvp;
    9using bsoncxx::builder::basic::make_document;
    10
    11int main() {
    12 try {
    13 mongocxx::instance inst{};
    14
    15 // Replace the placeholder with your Atlas connection string
    16 const auto uri = mongocxx::uri{"<connection-string>"};
    17
    18 // Connect to your cluster
    19 auto client = mongocxx::client{uri};
    20 auto db = client["sample_mflix"];
    21 auto collection = db["embedded_movies"];
    22
    23 // Define vector embeddings to search
    24 auto vectors = bsoncxx::builder::list{
    25 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234
    26 };
    27
    28 // Define the pipeline with vectorSearch query options
    29 mongocxx::pipeline stages;
    30
    31 stages
    32 .append_stage(make_document(
    33 kvp("$vectorSearch",
    34 make_document(kvp("index", "vector_index"),
    35 kvp("path", "plot_embedding_voyage_3_large"),
    36 kvp("queryVector", vectors),
    37 kvp("numCandidates", 150), kvp("limit", 10)))))
    38 .project(make_document(
    39 kvp("_id", 0), kvp("plot", 1), kvp("title", 1),
    40 kvp("score", make_document(kvp("$meta", "vectorSearchScore")))));
    41
    42 auto cursor = collection.aggregate(stages);
    43
    44 for (auto&& doc : cursor) {
    45 std::cout << bsoncxx::to_json(doc) << std::endl;
    46 }
    47 } catch (const std::exception& e) {
    48 std::cout << "Exception: " << e.what() << std::endl;
    49 }
    50 return 0;
    51}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3
  1. Replace the vector_index.cpp file name in your CMakeLists.txt file with your new atlas_vector_search_quick_start.cpp filename.

  2. Navigate to the /build directory, and prepare the project.

    cmake ../
  3. Build the app.

    cmake --build .
  4. Execute the app to run the query.

    ./query_quick_start
    1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
    2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
    3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
    4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
    5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
    6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
    7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
    8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
    9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
    10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a new file called DatabaseService.cs.

  2. Copy and paste the following sample query into the DatabaseService.cs file:

    DatabaseService.cs
    1namespace query_quick_start;
    2
    3using MongoDB.Bson;
    4using MongoDB.Bson.Serialization.Attributes;
    5using MongoDB.Bson.Serialization.Conventions;
    6using MongoDB.Driver;
    7
    8public class DatabaseService
    9{
    10 // Replace the placeholder with your Atlas connection string
    11 private const string MongoConnectionString = "<connection-string>";
    12
    13 public void RunVectorQuery(){
    14 var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
    15 ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
    16
    17 // connect to your cluster
    18 var mongoClient = new MongoClient(MongoConnectionString);
    19
    20 // define namespace
    21 var moviesDatabase = mongoClient.GetDatabase("sample_mflix");
    22 var moviesCollection = moviesDatabase.GetCollection<EmbeddedMovie>("embedded_movies");
    23
    24 // define vector embeddings to search
    25 var vector = new[] {-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234};
    26 var options = new VectorSearchOptions<EmbeddedMovie>() {
    27 IndexName = "vector_index",
    28 NumberOfCandidates = 150
    29 };
    30
    31 // run query
    32 var results = moviesCollection.Aggregate()
    33 .VectorSearch(movie => movie.Embedding, vector, 10, options)
    34 .Project(Builders<EmbeddedMovie>.Projection
    35 .Include(movie => movie.Title)
    36 .Include(movie => movie.Plot)
    37 .Exclude(movie => movie.Id)
    38 .MetaVectorSearchScore(movie => movie.Score))
    39 .ToList();
    40
    41 // print results
    42 foreach (var movie in results)
    43 {
    44 Console.WriteLine(movie.ToJson());
    45 }
    46 }
    47}
    48
    49[BsonIgnoreExtraElements]
    50public class EmbeddedMovie
    51{
    52 [BsonIgnoreIfDefault]
    53 public ObjectId Id { get; set; }
    54 public string? Title { get; set; }
    55 public string? Plot { get; set; }
    56 [BsonElement("plot_embedding_voyage_3_large")]
    57 public double[]? Embedding { get; set; }
    58 public double Score { get; set; }
    59}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Remove the index creation code from your Program.cs file. Instead, initialize the DatabaseService object and call the method to run the query:

Program.cs
using query_quick_start;
var databaseService = new DatabaseService();
databaseService.RunVectorQuery();
4

Compile and run your project.

dotnet run query-quick-start.csproj
1{ "plot" : "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title" : "About Time", "score" : 0.7710106372833252 }
2{ "plot" : "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title" : "Retroactive", "score" : 0.76004797220230103 }
3{ "plot" : "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title" : "A.P.E.X.", "score" : 0.75768613815307617 }
4{ "plot" : "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title" : "Timecop", "score" : 0.75765615701675415 }
5{ "plot" : "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title" : "Back to the Future Part II", "score" : 0.7521393895149231 }
6{ "plot" : "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title" : "Thrill Seekers", "score" : 0.75099325180053711 }
7{ "plot" : "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title" : "Timerider: The Adventure of Lyle Swann", "score" : 0.75026428699493408 }
8{ "plot" : "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title" : "The Time Machine", "score" : 0.75025033950805664 }
9{ "plot" : "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title" : "The Time Traveler's Wife", "score" : 0.74949634075164795 }
10{ "plot" : "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title" : "The Final Countdown", "score" : 0.7469133734703064 }
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named BasicQuery.java.

  2. Copy and paste the following sample query into the BasicQuery.java file:

    1import com.mongodb.client.MongoClient;
    2import com.mongodb.client.MongoClients;
    3import com.mongodb.client.MongoCollection;
    4import com.mongodb.client.MongoDatabase;
    5import com.mongodb.client.model.search.FieldSearchPath;
    6import org.bson.Document;
    7import org.bson.conversions.Bson;
    8
    9import java.util.List;
    10
    11import static com.mongodb.client.model.Aggregates.project;
    12import static com.mongodb.client.model.Aggregates.vectorSearch;
    13import static com.mongodb.client.model.Projections.fields;
    14import static com.mongodb.client.model.Projections.include;
    15import static com.mongodb.client.model.Projections.exclude;
    16import static com.mongodb.client.model.Projections.metaVectorSearchScore;
    17import static com.mongodb.client.model.search.SearchPath.fieldPath;
    18import static com.mongodb.client.model.search.VectorSearchOptions.approximateVectorSearchOptions;
    19import static java.util.Arrays.asList;
    20
    21public class BasicQuery {
    22 public static void main( String[] args ) {
    23 // specify connection
    24 String uri = "<connection-string>";
    25
    26 // establish connection and set namespace
    27 try (MongoClient mongoClient = MongoClients.create(uri)) {
    28 MongoDatabase database = mongoClient.getDatabase("sample_mflix");
    29 MongoCollection<Document> collection = database.getCollection("embedded_movies");
    30
    31
    32 // define $vectorSearch query options
    33 List<Double> queryVector = (asList(-0.034731735d,0.008558298d,-0.0153717d,-0.029912498d,0.011549547d,0.010261648d,-0.011964999d,-0.023265276d,0.010303194d,-0.006896493d,-0.00054528d,0.003926015d,-0.025757983d,0.027419789d,0.001199616d,-0.036227357d,-0.005297005d,0.021935832d,0.010303194d,-0.019193852d,0.025093261d,-0.040049512d,-0.033900831d,-0.011466458d,-0.01827986d,-0.0153717d,0.023265276d,0.007727395d,0.000114249d,0.005317777d,-0.043871664d,-0.02127111d,-0.019609304d,0.016368784d,-0.004756918d,0.003552109d,0.006522586d,-0.005400868d,-0.015620971d,-0.034565553d,-0.018695312d,-0.023099095d,0.050851244d,-0.034731735d,0.004819236d,0.022268193d,-0.095719993d,0.05517194d,-0.046198189d,-0.036393538d,0.007187308d,-0.02459472d,-0.036725901d,0.009472291d,0.019027673d,0.020938748d,-0.011051006d,0.027087428d,0.04586583d,-0.022600554d,-0.05517194d,0.044204023d,0.01213118d,0.047859997d,-0.03938479d,0.002928932d,0.002056484d,0.019443123d,-0.028583053d,0.013543714d,0.022932915d,0.011632638d,0.004923099d,0.000389486d,0.020024756d,-0.024096178d,-0.022766734d,0.011217186d,-0.003198975d,0.007104218d,-0.047195274d,-0.013377533d,0.013294443d,0.024096178d,-0.056501385d,-0.026755067d,-0.008433662d,-0.001911076d,0.007976666d,-0.008101301d,-0.014042255d,0.008641388d,-0.02176965d,0.010012378d,-0.000607598d,-0.024927082d,0.024927082d,-0.018612221d,-0.001184036d,0.005567048d,0.001324251d,-0.019526213d,-0.023597637d,0.060489718d,-0.010178559d,-0.019609304d,0.004112968d,-0.011217186d,-0.031574301d,-0.008766023d,0.005483958d,-0.061819162d,-0.023431456d,-0.040714234d,0.015039339d,0.026422706d,0.016202603d,0.004653055d,0.041046593d,-0.018030589d,0.040381871d,-0.002638116d,0.013045172d,0.004216831d,0.005650138d,0.027419789d,0.003926015d,-0.028749233d,0.004798463d,-0.030244859d,0.063813329d,0.007145763d,-0.017448956d,0.025591804d,-0.045201108d,0.010718645d,0.002804297d,0.014291527d,0.04586583d,-0.015205519d,-0.021603471d,-0.035230275d,0.00760276d,0.033236109d,0.016534964d,-0.043206941d,-0.003115885d,-0.026256526d,0.005940954d,0.016534964d,0.024262359d,-0.001630647d,0.028084511d,-0.012795902d,0.007270399d,0.001381376d,-0.009763107d,-0.006896493d,0.008433662d,-0.019360034d,0.000386889d,0.030411039d,0.025591804d,0.010469374d,0.037722982d,-0.001147684d,-0.005400868d,0.052845411d,-0.052513052d,0.00768585d,-0.004299921d,0.00922302d,0.011881908d,0.012962082d,-0.068798743d,0.003593654d,0.020938748d,-0.013792985d,-0.034565553d,-0.007519669d,-0.04021569d,-0.020689478d,0.006273315d,0.046862911d,0.006107135d,0.002638116d,-0.013792985d,-0.005400868d,-0.020274026d,0.007644305d,-0.010801735d,0.026422706d,0.043871664d,0.003780607d,0.010261648d,-0.064145692d,0.011881908d,-0.009056839d,0.009347656d,-0.02459472d,0.026422706d,0.033236109d,0.041212775d,0.019027673d,-0.00315743d,0.004424557d,0.020689478d,-0.0153717d,-0.015205519d,-0.034897912d,0.020274026d,0.016867325d,0.040714234d,-0.022766734d,-0.010967916d,0.026256526d,0.007062673d,-0.015953332d,-0.007727395d,0.031574301d,-0.002887387d,-0.00614868d,0.004569965d,0.019027673d,0.012878992d,0.011798819d,0.004258377d,-0.019193852d,-0.021437289d,-0.021603471d,0.000301202d,-0.051183607d,-0.004985416d,-0.030078677d,0.012629721d,0.065142773d,-0.031740483d,-0.021104928d,-0.03938479d,-0.003365156d,-0.016036423d,0.036393538d,0.009804652d,-0.018612221d,0.060489718d,-0.003697517d,0.000547876d,0.063480966d,0.02758597d,0.010053922d,-0.003655972d,-0.001485239d,0.018362951d,0.021104928d,-0.003905243d,0.019443123d,-0.002658889d,-0.00380138d,-0.013626805d,0.035894997d,0.035396457d,-0.005691683d,0.002762751d,0.012878992d,-0.009596926d,-0.009970833d,-0.015953332d,0.022434372d,0.00614868d,-0.021188019d,0.001557943d,-0.020190936d,0.009763107d,0.017448956d,0.006730312d,0.005567048d,0.019692395d,-0.00218112d,-0.016867325d,0.006854947d,0.007976666d,0.019193852d,0.040880412d,0.007353489d,-0.02127111d,-0.031906664d,-0.026755067d,-0.017947499d,0.040381871d,0.042209856d,0.00913993d,-0.0307434d,-0.017781317d,-0.015039339d,0.03057722d,0.017532047d,0.0187784d,-0.060822077d,0.002928932d,-0.026422706d,-0.005899409d,0.039717149d,0.026588887d,-0.000971118d,0.004923099d,-0.013626805d,0.0187784d,-0.031408124d,-0.000695881d,0.050851244d,-0.014457707d,-0.007311944d,-0.001293092d,-0.002139574d,-0.019276943d,0.00290816d,0.019360034d,-0.017781317d,0.002160347d,0.016618054d,-0.006522586d,0.011798819d,0.029247776d,-0.02775215d,0.010344739d,-0.018362951d,-0.036725901d,-0.015870241d,0.015704062d,-0.012463541d,0.02459472d,-0.024096178d,0.001152877d,-0.031408124d,0.025425622d,0.027087428d,0.00922302d,0.034565553d,0.015704062d,-0.020689478d,-0.00517237d,-0.014706978d,-0.001589101d,0.026090344d,0.014956249d,0.011715728d,0.004299921d,-0.00913993d,0.022434372d,-0.03705826d,0.048524719d,-0.030411039d,0.008433662d,0.017033506d,-0.000511525d,-0.031408124d,0.005940954d,-0.012962082d,-0.031574301d,0.017448956d,0.010178559d,-0.011383367d,-0.020107845d,-0.005151597d,0.006647222d,0.013128263d,0.007145763d,0.008059756d,-0.045201108d,-0.004943871d,0.015787151d,-0.045201108d,-0.020772567d,-0.020274026d,0.028250692d,-0.024262359d,-0.004424557d,0.009804652d,0.000472576d,-0.005691683d,0.001443693d,-0.013294443d,0.001412535d,0.013211353d,-0.01213118d,-0.002118802d,0.017781317d,-0.007353489d,-0.031075761d,-0.004923099d,0.011383367d,-0.004486875d,-0.010178559d,0.016618054d,0.014457707d,0.023763817d,-0.02459472d,-0.00388447d,0.012546631d,-0.007519669d,0.015704062d,-0.014291527d,0.009680017d,-0.035562634d,0.023763817d,0.053510133d,-0.0555043d,-0.003572882d,0.022102011d,0.021603471d,-0.017282777d,-0.001474852d,-0.043539301d,0.007810486d,-0.025757983d,-0.005400868d,0.029912498d,-0.00760276d,0.014125346d,0.030909581d,-0.03340229d,-0.009680017d,0.018030589d,0.008849114d,0.03057722d,0.019775484d,0.014125346d,0.031906664d,-0.03057722d,-0.027087428d,-0.023597637d,-0.022434372d,-0.012878992d,0.016285693d,-0.021603471d,-0.029746316d,0.029746316d,0.020357117d,0.006314861d,-0.001158071d,0.028749233d,-0.045201108d,0.011383367d,0.011134096d,-0.021437289d,-0.035728816d,0.001827986d,0.008267482d,-0.057498466d,0.01213118d,-0.01213118d,-0.040548053d,0.010718645d,0.004798463d,-0.004881553d,-0.019526213d,-0.008558298d,0.0059825d,-0.000262254d,-0.017615138d,0.005193142d,0.019692395d,-0.00198378d,-0.002845842d,0.012546631d,0.006107135d,-0.008225936d,-0.008890659d,0.015870241d,0.00517237d,0.002596571d,-0.010427829d,-0.019110762d,0.024262359d,0.012048089d,-0.032405205d,0.006522586d,0.013211353d,0.013211353d,-0.038221523d,-0.007727395d,-0.008267482d,-0.019276943d,0.001474852d,0.031408124d,-0.035562634d,0.017532047d,-0.023431456d,-0.015454791d,-0.011383367d,0.016534964d,-0.02176965d,0.008682934d,0.027253609d,0.020190936d,-0.0247609d,-0.007311944d,0.009555381d,-0.01852913d,-0.011632638d,0.011549547d,0.027419789d,-0.034067012d,-0.01229736d,0.0307434d,0.003946788d,0.0046946d,0.037722982d,0.03057722d,-0.010427829d,0.002284982d,0.033236109d,0.030078677d,-0.013377533d,0.007395034d,-0.012048089d,0.040714234d,-0.028749233d,-0.000102565d,-0.0059825d,-0.041046593d,0.017698228d,-0.006356406d,0.003178203d,0.009056839d,0.023099095d,0.00606559d,0.011881908d,-0.02127111d,-0.001126912d,-0.027087428d,0.011134096d,0.001204809d,-0.017033506d,0.011051006d,-0.014374617d,0.017864408d,0.023431456d,-0.002077257d,-0.026755067d,-0.043871664d,0.025757983d,-0.006190225d,0.001152877d,0.011798819d,-0.024262359d,0.006564131d,-0.070128188d,-0.004362239d,0.012962082d,-0.013626805d,-0.001402148d,-0.012214269d,0.011217186d,-0.015953332d,0.015787151d,0.011134096d,0.027253609d,0.024262359d,-0.048192356d,0.009970833d,0.018944582d,-0.00517237d,0.021935832d,0.02775215d,0.003406701d,-0.010884825d,0.075113602d,-0.015953332d,0.007727395d,0.026755067d,-0.006190225d,-0.012712811d,0.013377533d,0.005940954d,-0.008309027d,0.02459472d,0.002316141d,-0.022434372d,-0.012712811d,0.03057722d,-0.015787151d,0.026755067d,-0.001069787d,0.03988333d,-0.003697517d,0.039550968d,-0.019027673d,-0.0059825d,-0.00031029d,-0.012546631d,-0.003614427d,0.007478124d,0.005525503d,0.032571387d,-0.011798819d,-0.011466458d,-0.00606559d,-0.011798819d,0.018446039d,0.007976666d,0.018944582d,-0.02176965d,0.026588887d,-0.006273315d,-0.012463541d,-0.007395034d,0.012048089d,-0.029247776d,0.015454791d,-0.007145763d,0.006481041d,-0.015620971d,-0.00388447d,-0.025757983d,-0.001651419d,-0.032903746d,-0.005068507d,0.03938479d,0.003926015d,0.004715373d,0.022600554d,-0.012546631d,0.022932915d,0.007810486d,0.040714234d,0.019941665d,0.013543714d,0.003406701d,0.010884825d,-0.03988333d,0.042209856d,-0.022766734d,0.027419789d,-0.029580137d,0.043206941d,0.022932915d,0.021104928d,-0.056833744d,0.005193142d,0.036061179d,-0.012878992d,0.008516753d,-0.02758597d,-0.030244859d,-0.011798819d,0.001111332d,-0.014125346d,-0.014125346d,0.019027673d,0.029081594d,0.018861491d,0.013626805d,0.06846638d,0.023099095d,0.041378956d,0.001599488d,-0.028749233d,0.017781317d,0.016285693d,0.021603471d,-0.018113678d,0.011300277d,-0.032239024d,0.022434372d,-0.02459472d,-0.013626805d,0.005483958d,0.013460624d,-0.031574301d,-0.015620971d,0.016451873d,0.014790068d,-0.008849114d,0.011134096d,0.00461151d,0.015122429d,0.036227357d,0.00206687d,0.000877641d,0.022102011d,-0.028250692d,0.022600554d,-0.026422706d,0.004029878d,-0.032072846d,0.017116595d,0.010884825d,0.019609304d,0.00614868d,0.005733229d,0.016119512d,0.002866614d,-0.014540797d,0.012463541d,-0.003905243d,0.003759835d,-0.000485559d,-0.022766734d,-0.016285693d,0.037722982d,0.009513836d,0.001506011d,0.011964999d,0.004029878d,0.019941665d,-0.000965924d,0.002129188d,0.015205519d,0.071125269d,0.022932915d,0.005940954d,-0.00044661d,0.010220103d,-0.03423319d,-0.016285693d,-0.016867325d,-0.000659529d,-0.008018211d,-0.011383367d,0.000016634d,0.004071423d,-0.029413955d,0.019941665d,-0.00913993d,-0.024096178d,0.010635555d,0.010594009d,0.001547556d,0.036227357d,-0.030078677d,0.020772567d,0.022268193d,-0.014125346d,0.008766023d,-0.012962082d,-0.007187308d,0.017033506d,-0.007187308d,-0.015205519d,-0.005608593d,0.044536386d,-0.001235968d,0.007852031d,0.001599488d,0.005857864d,-0.005940954d,-0.010510919d,-0.005567048d,0.006730312d,0.016285693d,-0.010801735d,-0.024428539d,0.015122429d,-0.02176965d,0.01528861d,-0.007436579d,0.00226421d,-0.004715373d,0.004507647d,0.004341467d,0.005525503d,-0.031075761d,-0.005899409d,0.037556801d,0.014873158d,-0.000342747d,0.009970833d,-0.019443123d,0.023597637d,-0.012048089d,-0.025259443d,0.006024044d,-0.01827986d,0.010012378d,0.016784234d,0.013211353d,-0.005400868d,-0.024428539d,-0.02176965d,-0.035230275d,0.009347656d,0.028583053d,-0.015704062d,-0.017781317d,0.00226421d,0.001199616d,-0.003385928d,0.008267482d,0.002326528d,0.022434372d,-0.020190936d,-0.015787151d,0.000789358d,0.031241942d,0.011300277d,0.001506011d,-0.023265276d,-0.010967916d,0.009056839d,0.011300277d,-0.030244859d,0.007478124d,0.001111332d,-0.035894997d,0.0153717d,0.002700434d,0.021104928d,0.010884825d,-0.003344383d,0.00768585d,0.010386284d,0.00452842d,-0.014706978d,0.028084511d,0.013377533d,0.014873158d,0.046862911d,-0.015454791d,0.021188019d,0.013959166d,0.012629721d,0.025924165d,-0.018695312d,-0.00922302d,-0.0093892d,0.007727395d,0.036892079d,0.007228854d,-0.01229736d,0.029247776d,-0.004943871d,-0.027253609d,-0.008433662d,0.043206941d,0.002825069d,0.028583053d,-0.023431456d,0.034897912d,-0.041545134d,-0.016534964d,0.003053567d,-0.012712811d,0.002741979d,-0.007187308d,-0.025093261d,-0.045201108d,-0.004424557d,-0.016618054d,-0.008890659d,0.008018211d,-0.05184833d,-0.019526213d,-0.013377533d,-0.010469374d,0.030244859d,-0.005068507d,0.051183607d,0.005483958d,-0.006024044d,0.035064094d,-0.011134096d,0.014956249d,0.002284982d,0.001724123d,-0.01229736d,0.012629721d,0.010261648d,0.014540797d,0.048857078d,-0.029580137d,-0.024927082d,-0.008350573d,-0.03988333d,0.000939959d,0.013543714d,0.013626805d,-0.021437289d,-0.012962082d,0.006771857d,0.013709894d,-0.0059825d,0.035396457d,-0.006439496d,-0.029580137d,0.0046946d,0.019609304d,-0.007270399d,0.014291527d,-0.015620971d,0.00118923d,-0.00760276d,-0.017199686d,0.023265276d,0.026588887d,-0.030078677d,-0.016701145d,-0.025757983d,0.004964644d,0.026588887d,0.043206941d,0.011051006d,-0.009846197d,0.028915415d,0.031574301d,0.023763817d,0.009264565d,-0.008433662d,-0.035064094d,-0.000579035d,-0.0247609d,0.014125346d,0.016618054d,0.028749233d,-0.052513052d,-0.016867325d,-0.01238045d,0.002741979d,0.013709894d,0.010718645d,0.013626805d,0.009596926d,-0.004403784d,-0.02758597d,-0.000945152d,0.000420645d,0.003759835d,0.012546631d,-0.011881908d,0.008392117d,0.012795902d,0.005483958d,-0.009763107d,0.006397951d,-0.010801735d,0.012795902d,-0.03938479d,0.005733229d,0.005733229d,-0.000433627d,0.015454791d,0.002357686d,-0.006564131d,0.030244859d,-0.024428539d,0.016036423d,0.014291527d,-0.004964644d,0.029413955d,0.040381871d,0.012629721d,-0.033568468d,-0.026422706d,-0.037889164d,-0.034399372d,-0.03423319d,0.021935832d,0.004133741d,-0.014623888d,-0.013543714d,-0.05517194d,0.004736145d,0.006314861d,0.00006037d,0.006356406d,0.003323611d,-0.010344739d,0.007062673d,0.005899409d,-0.00623177d,-0.001973394d,-0.0555043d,0.011881908d,0.001350217d,-0.033069927d,-0.026921248d,0.022268193d,0.028583053d,-0.021021837d,0.010884825d,0.019692395d,-0.005442413d,0.031574301d,-0.014956249d,0.01238045d,-0.006356406d,0.006273315d,-0.003095113d,-0.014540797d,-0.02176965d,0.005006189d,-0.002658889d,0.042542219d,-0.02176965d,0.017199686d,-0.016701145d,-0.001599488d,0.016950415d,-0.021188019d,0.017864408d,0.023763817d,-0.000669915d,0.025093261d,0.021104928d,0.008807569d,0.037390623d,-0.025591804d,-0.003178203d,-0.001319058d,0.020523297d,0.005255459d,0.019276943d,-0.00226421d,0.00760276d,-0.057166107d,-0.006896493d,-0.034067012d,0.043871664d,0.038221523d,0.008101301d,0.03988333d,0.015870241d,0.000955538d,-0.004299921d,-0.002928932d,-0.002118802d,-0.020523297d,-0.001168457d,-0.011134096d,-0.000685495d,0.003323611d,0.011549547d,0.034565553d,0.029247776d,-0.029746316d,0.005213914d,0.019110762d,-0.003302838d,0.026422706d,0.028915415d,-0.036227357d,0.033236109d,0.038387705d,-0.035230275d,0.004071423d,-0.021935832d,0.002928932d,0.000976311d,0.000527104d,-0.006854947d,-0.003822153d,-0.001199616d,0.019858574d,-0.002762751d,0.039052427d,-0.008641388d,0.032239024d,-0.002295369d,0.035396457d,0.044536386d,-0.029413955d,0.025093261d,-0.03423319d,-0.016867325d,-0.008849114d,0.008433662d,-0.004486875d,0.017033506d,0.006730312d,-0.008599843d,-0.008225936d,-0.024428539d,0.006564131d,-0.007561215d,-0.032072846d,-0.019941665d,0.035396457d,0.019276943d,0.010261648d,0.005857864d,0.032239024d,-0.044204023d,-0.018944582d,0.002409618d,0.032903746d,0.05517194d,-0.03655972d,0.007976666d,0.030909581d,-0.023929998d,0.016368784d,0.01528861d,-0.00768585d,0.02176965d,0.013626805d,-0.02459472d,0.04021569d,-0.032737568d,0.006854947d,-0.011383367d,0.014873158d,-0.02176965d,0.00243039d,0.0093892d,0.0093892d,-0.029580137d,0.019858574d,0.01827986d,0.024428539d,0.017864408d,-0.028250692d,-0.001111332d,0.056169022d,0.007478124d,-0.010718645d,0.041046593d,-0.015704062d,0.034731735d,0.002523867d,-0.032571387d,0.004341467d,-0.023597637d,-0.011881908d,-0.035562634d,0.006688767d,0.007810486d,-0.012712811d,0.022600554d,0.03057722d,0.022600554d,0.010552464d,0.0307434d,-0.009638472d,0.02176965d,-0.018030589d,0.024262359d,-0.036227357d,-0.020772567d,0.001641033d,-0.022932915d,-0.014623888d,0.018362951d,0.002575798d,0.006190225d,-0.011051006d,0.021021837d,0.019110762d,0.02127111d,-0.028583053d,-0.052180689d,-0.014291527d,-0.010552464d,0.036393538d,0.042542219d,-0.04586583d,-0.001869531d,0.008350573d,-0.008516753d,-0.020772567d,0.000294711d,0.015704062d,-0.014457707d,-0.020772567d,0.008766023d,-0.026588887d,-0.004736145d,-0.028084511d,-0.007519669d,0.010552464d,-0.016534964d,0.006190225d,0.012962082d,-0.016618054d,0.012546631d,0.02459472d,0.022932915d,0.020440206d,-0.027918331d,-0.008059756d,0.020689478d,-0.014623888d,-0.011466458d,-0.006896493d,-0.020024756d,-0.031408124d,0.021603471d,0.007270399d,-0.03057722d,0.008350573d,-0.021437289d,0.00072704d,-0.043871664d,0.006314861d,-0.017199686d,0.02176965d,0.024262359d,-0.020357117d,-0.000542683d,-0.005213914d,0.001963008d,-0.00064395d,-0.022434372d,0.022102011d,-0.006688767d,-0.028583053d,0.002191506d,-0.005047734d,0.002368073d,0.014956249d,0.023929998d,-0.003302838d,-0.032239024d,0.022268193d,-0.013377533d,-0.010801735d,0.003676744d,0.009015295d,-0.039550968d,0.010884825d,-0.033568468d,0.013709894d,-0.029413955d,-0.006356406d,-0.020274026d,0.023597637d,0.030909581d,0.02176965d,0.016285693d,0.045533467d,-0.024096178d,-0.030909581d,-0.026422706d,0.002783524d,-0.010594009d,0.004362239d,-0.070792913d,0.009472291d,-0.022102011d,0.011134096d,-0.017448956d,-0.011549547d,-0.056833744d,0.00082571d,0.026588887d,-0.013709894d,0.002575798d,0.02176965d,-0.000568649d,-0.007270399d,0.004279149d,-0.042874578d,-0.026588887d,0.016784234d,0.036725901d,-0.028915415d,-0.009513836d,0.017448956d,0.002035712d,-0.007228854d,0.011383367d,0.011134096d,0.028915415d,0.0153717d,-0.027087428d,0.043871664d,-0.005089279d,0.006314861d,0.014291527d,-0.003240521d,0.025924165d,-0.001230775d,-0.015454791d,-0.012629721d,0.031740483d,-0.039717149d,-0.031075761d,0.006605676d,-0.008641388d,-0.032239024d,0.037722982d,-0.03705826d,-0.024096178d,0.001911076d,0.018196769d,-0.007353489d,-0.011300277d,-0.029081594d,0.004590738d,-0.018030589d,-0.026588887d,0.010261648d,0.038221523d,0.008392117d,-0.01213118d,0.018362951d,-0.034731735d,-0.017781317d,-0.011632638d,0.005255459d,0.000851675d,0.014208436d,-0.000039922d,-0.000228498d,0.014790068d,0.00913993d,0.0004544d,-0.011798819d,-0.020440206d,0.005899409d,0.008350573d,0.006314861d,0.040548053d,0.003427474d,-0.010801735d,0.008599843d,0.002586185d,-0.041212775d,-0.016368784d,0.020024756d,0.000965924d,-0.021021837d,-0.008475208d,0.0307434d,0.00760276d,0.003614427d,0.003489791d,-0.025924165d,0.000799744d,0.013460624d,-0.020440206d,0.048857078d,0.004320694d,-0.048857078d,0.015039339d,-0.029580137d,0.025924165d,0.018861491d,-0.014706978d,0.000576439d,-0.031241942d,0.0307434d,0.0153717d,0.014706978d,0.028084511d,-0.01238045d,-0.031241942d,0.018196769d,-0.034897912d,0.008142847d,0.010718645d,0.00922302d,0.047859997d,-0.00072704d,-0.010427829d,0.007104218d,0.026256526d,0.012214269d,-0.013377533d,-0.05184833d,0.005276232d,0.021935832d,-0.007021128d,0.009804652d,0.007893575d,0.024096178d,-0.002357686d,0.033900831d,-0.031740483d,0.034565553d,-0.036892079d,-0.015454791d,0.030411039d,0.010552464d,-0.022268193d,-0.001391762d,-0.008184392d,-0.008558298d,0.008475208d,-0.009929287d,0.010427829d,0.041378956d,-0.009555381d,-0.008724478d,-0.039052427d,0.034731735d,-0.014291527d,0.023099095d,0.029081594d,0.007519669d,0.010967916d,-0.008142847d,0.006190225d,-0.031075761d,0.033734649d,-0.001672192d,0.047859997d,-0.022434372d,-0.007395034d,0.01213118d,0.056169022d,0.002762751d,-0.029413955d,-0.000763392d,-0.015787151d,0.010801735d,0.008142847d,0.029912498d,-0.0018176d,0.033236109d,-0.046198189d,-0.002492708d,-0.006730312d,0.008807569d,-0.03655972d,0.009430746d,-0.053842496d,-0.060489718d,0.046862911d,0.002783524d,-0.0187784d,0.000571246d,0.00760276d,0.002482322d,0.001319058d,-0.014291527d,0.001464466d,-0.011632638d,-0.012463541d,-0.004902326d,0.000841289d,0.006688767d,0.030244859d,0.018944582d,0.000532297d,-0.015620971d,0.007104218d,0.005608593d,0.002035712d,-0.023763817d,0.003032795d,0.010594009d,-0.023597637d,-0.042376038d,-0.005255459d,0.001199616d,-0.0247609d,-0.007893575d,-0.011632638d,0.013045172d,-0.005691683d,-0.007104218d,0.027419789d,-0.004320694d,-0.005525503d,-0.026090344d,0.031408124d,-0.012795902d,-0.007062673d,0.000939959d,0.000030185d,0.004175286d,0.014291527d,0.033236109d,-0.038720068d,0.074116521d,-0.019692395d,0.001589101d,0.013792985d,-0.056169022d,-0.028749233d,-0.001599488d,0.004175286d,0.014790068d,0.00162026d,-0.007519669d,-0.041378956d,0.016534964d,-0.003572882d,-0.002575798d,-0.019526213d,-0.00922302d,-0.033900831d,-0.042043675d,-0.014208436d,0.010178559d,0.017698228d,0.032239024d,0.00913993d,0.009264565d,-0.012463541d,-0.005857864d,-0.015870241d,0.004486875d,0.018861491d,-0.000176567d,-0.029912498d,0.016784234d,0.012546631d,0.051183607d,0.023597637d,0.032903746d,0.0153717d,-0.013377533d,-0.000016634d,-0.061486799d,-0.034565553d,0.016119512d,0.00380138d,-0.003863698d,0.004362239d,-0.017532047d,-0.002762751d,0.000102565d,-0.021437289d,0.029247776d,-0.010718645d,-0.015870241d,-0.016285693d,0.010220103d,-0.000373906d,0.012962082d,0.010137013d,-0.007228854d,0.02127111d,-0.029247776d,0.018113678d,0.009181475d,0.002233051d,0.014374617d,-0.00396756d,0.010801735d,0.007644305d,0.020855658d,0.014790068d,0.032737568d,-0.037390623d,0.003032795d,0.010801735d,-0.01553788d,-0.014790068d,0.019526213d,-0.017947499d,-0.007893575d,-0.011964999d,-0.00614868d,-0.005857864d,-0.032072846d,-0.025924165d,0.001163264d,-0.013294443d,-0.01553788d,0.016701145d,-0.013460624d,-0.001111332d,0.00760276d,0.01553788d,-0.033734649d,0.048192356d,-0.003282066d,0.031906664d,0.002845842d,0.003240521d,0.017116595d,-0.01827986d,0.006896493d,-0.00760276d,-0.009680017d,-0.02459472d,-0.020689478d,-0.053510133d,0.00614868d,-0.010552464d,-0.032405205d,-0.0307434d,0.025093261d,0.003635199d,-0.008101301d,-0.00606559d,-0.007436579d,0.00606559d,-0.012962082d,0.026921248d,0.009098385d,0.046530552d,-0.011632638d,0.032571387d,-0.033900831d,0.009846197d,0.002866614d,0.032903746d,0.008973749d,0.012712811d,0.040049512d,0.013626805d,-0.026256526d,-0.031408124d,0.036227357d,0.011964999d,-0.006024044d,-0.001848759d,0.015704062d,-0.021188019d,-0.035064094d,-0.013377533d,-0.009721561d,-0.01553788d,0.008766023d,0.005400868d,0.004507647d,-0.018362951d,-0.026588887d,-0.00913993d,-0.025591804d,0.035894997d,0.021935832d,-0.031906664d,-0.000602404d,0.026422706d,-0.006397951d,0.006647222d,0.0093892d,0.020606387d,0.00913993d,0.015620971d,-0.024096178d,0.00063616d,-0.006564131d,0.01238045d,-0.013709894d,0.000563456d,-0.009887742d,0.016618054d,-0.003323611d,0.000451803d,0.001609874d,0.008682934d,0.025259443d,0.020024756d,-0.027253609d,0.010884825d,0.028250692d,-0.054839578d,0.033568468d,-0.004902326d,0.003053567d,0.020274026d,-0.015704062d,-0.00614868d,-0.063813329d,0.002482322d,0.009763107d,-0.001609874d,-0.012214269d,0.020107845d,0.001921462d,0.018695312d,-0.004923099d,0.007270399d,-0.023763817d,0.005234687d,0.003406701d,0.002565412d,0.007104218d,0.000841289d,0.016202603d,0.01827986d,-0.031075761d,-0.035562634d,-0.025259443d,-0.007021128d,0.000641353d,-0.033069927d,0.010718645d,0.005650138d,0.024927082d,-0.002658889d,0.00380138d,0.009929287d,-0.004258377d,-0.039717149d,-0.022434372d,0.025425622d,0.00198378d,0.006356406d,0.017615138d,-0.032072846d,0.046862911d,-0.026921248d,0.005940954d,0.021603471d,-0.002253824d,0.002825069d,-0.030411039d,-0.003115885d,0.023597637d,-0.004320694d,-0.007852031d,0.018030589d,-0.008724478d,-0.005733229d,0.032903746d,0.013876075d,0.015454791d,-0.023597637d,0.005151597d,-0.035396457d,0.02176965d,-0.012463541d,0.025591804d,0.014540797d,-0.027918331d,0.004154514d,0.008724478d,0.016036423d,-0.015870241d,0.005400868d,-0.017365867d,-0.044868745d,-0.000485559d,0.020357117d,-0.00760276d,-0.023265276d,-0.012048089d,0.008433662d,0.018362951d,-0.006979583d,0.0307434d,0.008392117d,0.027087428d,-0.019360034d,0.016119512d,0.02127111d,0.010801735d,0.00299125d,0.002949705d,0.012463541d,-0.000025966d,0.015953332d,0.029413955d,0.020024756d,0.003780607d,0.022102011d,-0.031740483d,0.01553788d,0.010386284d,0.028749233d,-0.010884825d,0.008682934d,-0.003531337d,-0.05517194d,-0.019360034d,-0.009347656d,-0.002025325d,0.003261293d,-0.025425622d,-0.01553788d,-0.000251867d,0.014291527d,0.012546631d,0.035728816d,-0.007062673d,-0.006605676d,0.000384293d,-0.005047734d,-0.032571387d,-0.021188019d,-0.02127111d,-0.016036423d,0.008475208d,-0.004009106d,0.014291527d,-0.008101301d,0.004424557d,-0.038221523d,-0.019360034d,0.015039339d,-0.015454791d,-0.029580137d,0.035728816d,0.004466102d,-0.000778971d,-0.005068507d,-0.017781317d,0.00477769d,0.001838372d,0.030244859d,0.01213118d,-0.022932915d,-0.005359322d,0.037390623d,0.005899409d,0.002046098d,0.037889164d,0.016701145d,0.010303194d,0.02127111d,-0.009513836d,-0.022268193d,-0.005650138d,-0.00388447d,0.016534964d,-0.023265276d,-0.00054528d,0.004819236d,0.004715373d,-0.001178843d,-0.051183607d,-0.00614868d,-0.010552464d,-0.002741979d,-0.009181475d,0.023597637d,0.019193852d,0.017199686d,-0.036393538d,-0.00243039d,-0.015870241d,-0.014706978d,-0.00145408d,0.016368784d,-0.011632638d,-0.014623888d,-0.01229736d,-0.01553788d,0.040880412d,0.023929998d,-0.014623888d,0.002648502d,0.031906664d,-0.033734649d,-0.026755067d,0.002783524d,0.005359322d,0.009970833d,0.001412535d,0.016950415d,0.016285693d,-0.006730312d,-0.02459472d,0.050851244d,-0.001827986d,-0.020855658d,0.020938748d,0.004071423d,-0.021603471d,-0.007852031d,-0.023929998d,-0.029912498d,-0.003365156d,0.017365867d,-0.010427829d,-0.011715728d,0.014956249d,0.011383367d,0.032405205d,-0.028583053d,-0.017448956d,0.018446039d,0.017615138d,0.035728816d,-0.010095468d,-0.00254464d,0.010012378d,0.028250692d,-0.020855658d,-0.002305755d,-0.001002276d,-0.014125346d,-0.007021128d,-0.028583053d,-0.045533467d,-0.02758597d,-0.020440206d,0.001350217d,0.010053922d,0.020689478d,-0.017615138d,0.026422706d,0.040880412d,0.012463541d,-0.010718645d,-0.014706978d,0.068134025d,0.038720068d,0.047859997d,-0.012546631d,0.015704062d,-0.002087643d,-0.010303194d,0.014790068d,0.018612221d,0.007395034d,-0.014790068d,-0.017864408d,-0.005068507d,-0.054507218d,0.004902326d,-0.004050651d,0.021603471d,0.019775484d,-0.024262359d,-0.012795902d,0.021935832d,-0.004009106d,-0.039717149d,0.037556801d,-0.016701145d,-0.025757983d,0.005483958d,-0.005110051d,-0.021935832d,-0.003406701d,0.010594009d,0.015787151d,-0.049854163d,0.007727395d,-0.008392117d,-0.017199686d,0.009970833d,-0.008849114d,-0.013876075d,-0.0059825d,-0.015870241d,-0.007104218d,0.028250692d,-0.029081594d,0.026921248d,0.00299125d,-0.017781317d,0.042542219d,0.018196769d,0.052845411d,-0.004819236d,-0.014125346d,0.02459472d,-0.011715728d,0.015787151d,-0.005774774d,0.004902326d,-0.004964644d,-0.02758597d,-0.013959166d,-0.033568468d,-0.027918331d,-0.017698228d,0.003489791d,-0.020024756d,-0.021603471d,0.019360034d,0.028084511d,-0.002503094d,-0.018861491d,-0.002295369d,0.050851244d,-0.020689478d,-0.000459593d,-0.026090344d,0.002783524d,-0.005899409d,-0.026921248d,-0.0093892d,-0.004112968d,0.031574301d,0.003926015d,-0.032903746d,-0.046198189d,-0.019027673d,-0.00913993d,0.030411039d,-0.019443123d,0.001963008d,-0.005193142d,0.010884825d,-0.02127111d,-0.025259443d,0.032737568d,0.00089322d,0.003282066d,0.001713737d,-0.006439496d,0.016867325d,-0.031574301d,0.031075761d,-0.009970833d,0.022600554d,-0.023597637d,-0.014956249d,0.004009106d,0.00198378d,0.026588887d,-0.023431456d,-0.023763817d,-0.013294443d,-0.029746316d,0.001381376d,-0.042874578d,-0.00913993d,0.014873158d,0.016202603d,0.012878992d,-0.006024044d,0.009638472d,0.010552464d,-0.017033506d,-0.027087428d,0.044536386d,-0.038055345d,0.001329444d,-0.019609304d,0.023597637d,-0.043206941d,0.040049512d,0.017615138d,0.046862911d,0.02127111d,0.013294443d,-0.039550968d,-0.018861491d,-0.019609304d,-0.033734649d,0.00623177d,-0.017199686d,0.041212775d,-0.017781317d,-0.024262359d,0.054507218d,-0.009721561d,0.005816319d,-0.00206687d,-0.008766023d,0.017365867d,-0.000737426d,0.018362951d,-0.023597637d,-0.019110762d,0.021935832d,0.041545134d,-0.020357117d,-0.017615138d,0.044868745d,-0.018030589d,-0.032405205d,-0.050186522d,-0.014540797d,0.005213914d,-0.006688767d,0.047527634d,0.040714234d));
    34 String indexName = "vector_index";
    35 FieldSearchPath fieldSearchPath = fieldPath("plot_embedding_voyage_3_large");
    36 int limit = 10;
    37 int numCandidates = 150;
    38
    39 // define pipeline
    40 List<Bson> pipeline = asList(
    41 vectorSearch(
    42 fieldSearchPath,
    43 queryVector,
    44 indexName,
    45 limit,
    46 approximateVectorSearchOptions(numCandidates)),
    47 project(
    48 fields(exclude("_id"), include("title"), include("plot"),
    49 metaVectorSearchScore("score"))));
    50
    51 // run query and print results
    52 collection.aggregate(pipeline)
    53 .forEach(doc -> System.out.println(doc.toJson()));
    54 }
    55 }
    56}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Compile and run the BasicQuery.java file:

javac BasicQuery.java
java BasicQuery
1{"plot": "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title": "About Time", "score": 0.7710106372833252}
2{"plot": "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title": "Retroactive", "score": 0.760047972202301}
3{"plot": "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title": "A.P.E.X.", "score": 0.7576861381530762}
4{"plot": "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title": "Timecop", "score": 0.7576561570167542}
5{"plot": "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title": "Back to the Future Part II", "score": 0.7521393895149231}
6{"plot": "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title": "Thrill Seekers", "score": 0.7509932518005371}
7{"plot": "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title": "Timerider: The Adventure of Lyle Swann", "score": 0.7502642869949341}
8{"plot": "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title": "The Time Machine", "score": 0.7502503395080566}
9{"plot": "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title": "The Time Traveler's Wife", "score": 0.749496340751648}
10{"plot": "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title": "The Final Countdown", "score": 0.7469133734703064}
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlasVectorSearchQuery.kt.

  2. Copy and paste the following sample query into the atlasVectorSearchQuery.kt file:

    1import com.mongodb.client.model.Aggregates
    2import com.mongodb.client.model.Projections
    3import com.mongodb.client.model.search.SearchPath.fieldPath
    4import com.mongodb.client.model.search.VectorSearchOptions
    5import com.mongodb.kotlin.client.coroutine.MongoClient
    6import kotlinx.coroutines.flow.count
    7import org.bson.Document
    8
    9data class Movie(val title: String, val plot: String, val score: Double?)
    10
    11suspend fun main() {
    12
    13 // Replace the placeholder with your Atlas connection string
    14 val uri = "<connection-string>"
    15 val client = MongoClient.create(uri)
    16
    17 try {
    18 // Connect to your cluster
    19 val database = client.getDatabase("sample_mflix")
    20 val collection = database.getCollection<Movie>("embedded_movies")
    21
    22 // Define the pipeline with $vectorSearch query options
    23 val queryVector = listOf(
    24 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234,
    25 )
    26 val path = fieldPath("plot_embedding_voyage_3_large")
    27 val index = "vector_index"
    28 val limit = 10L
    29 val numCandidates = 150L
    30
    31 val pipeline = listOf(
    32 Aggregates.vectorSearch(
    33 path,
    34 queryVector,
    35 index,
    36 limit,
    37 VectorSearchOptions.approximateVectorSearchOptions(numCandidates)
    38 ),
    39 Aggregates.project(
    40 Projections.fields(
    41 Projections.excludeId(),
    42 Projections.include(Movie::plot.name),
    43 Projections.include(Movie::title.name),
    44 Projections.metaVectorSearchScore(Movie::score.name)
    45 )
    46 )
    47 )
    48
    49 // Run the pipeline
    50 val resultsFlow = collection.aggregate<Document>(pipeline)
    51
    52 // Print results
    53 val resultCount = resultsFlow.count()
    54 if (resultCount > 0) {
    55 resultsFlow.collect { result ->
    56 println(result.toJson())
    57 }
    58 } else {
    59 println("No results found.")
    60 }
    61 } catch (e: Exception) {
    62 println("Error occurred: ${e.message}")
    63 } finally {
    64 client.close()
    65 }
    66}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the atlasVectorSearchQuery.kt file in your IDE. The output should resemble the following:

1{"plot": "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title": "About Time", "score": 0.7710106372833252}
2{"plot": "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title": "Retroactive", "score": 0.760047972202301}
3{"plot": "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title": "A.P.E.X.", "score": 0.7576861381530762}
4{"plot": "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title": "Timecop", "score": 0.7576561570167542}
5{"plot": "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title": "Back to the Future Part II", "score": 0.7521393895149231}
6{"plot": "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title": "Thrill Seekers", "score": 0.7509932518005371}
7{"plot": "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title": "Timerider: The Adventure of Lyle Swann", "score": 0.7502642869949341}
8{"plot": "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title": "The Time Machine", "score": 0.7502503395080566}
9{"plot": "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title": "The Time Traveler's Wife", "score": 0.749496340751648}
10{"plot": "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title": "The Final Countdown", "score": 0.7469133734703064}
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.js .

  2. Copy and paste the following sample query into the atlas-vector-search-quick-start.js file:

    1const { MongoClient } = require("mongodb");
    2
    3// connect to your cluster
    4const uri = "<connection-string>";
    5
    6const client = new MongoClient(uri);
    7
    8async function run() {
    9 try {
    10 await client.connect();
    11
    12 // set namespace
    13 const database = client.db("sample_mflix");
    14 const coll = database.collection("embedded_movies");
    15
    16 // define pipeline
    17 const agg = [
    18 {
    19 '$vectorSearch': {
    20 'index': 'vector_index',
    21 'path': 'plot_embedding_voyage_3_large',
    22 'queryVector': [
    23 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234
    24 ],
    25 'numCandidates': 150,
    26 'limit': 10
    27 }
    28 }, {
    29 '$project': {
    30 '_id': 0,
    31 'plot': 1,
    32 'title': 1,
    33 'score': {
    34 '$meta': 'vectorSearchScore'
    35 }
    36 }
    37 }
    38 ];
    39 // run pipeline
    40 const result = coll.aggregate(agg);
    41
    42 // print results
    43 await result.forEach((doc) => console.dir(JSON.stringify(doc)));
    44 } finally {
    45 await client.close();
    46 }
    47}
    48run().catch(console.dir);

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

node atlas-vector-search-quick-start.js
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.php.

  2. Copy and paste the following sample query into the atlas-vector-search-quick-start.php file:

    atlas-vector-search-quick-start.php
    1<?php
    2
    3require 'vendor/autoload.php';
    4
    5// Replace the placeholder with your Atlas connection string
    6$uri = '<connection-string>';
    7
    8try {
    9
    10 // Connect to your cluster
    11 $client = new MongoDB\Client($uri);
    12
    13 // Set the namespace
    14 $database = $client->selectDatabase('sample_mflix');
    15 $collection = $database->selectCollection('embedded_movies');
    16
    17 // Define the pipeline with $vectorSearch query options
    18 $pipeline = [
    19 [
    20 '$vectorSearch' => [
    21 'queryVector' => [
    22 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234
    23 ],
    24 'index' => 'vector_index',
    25 'path' => 'plot_embedding_voyage_3_large',
    26 'numCandidates' => 150,
    27 'limit' => 10
    28 ]
    29 ],
    30 [
    31 '$project' => [
    32 '_id' => 0,
    33 'plot' => 1,
    34 'title' => 1,
    35 'score' => [
    36 '$meta' => 'vectorSearchScore'
    37 ]
    38 ]
    39 ]
    40 ];
    41
    42 // Run the pipeline
    43 $result = $collection->aggregate($pipeline);
    44
    45 // Print results
    46 foreach ($result as $document) {
    47 echo json_encode($document) . "\n";
    48 }
    49
    50} catch (MongoDB\Driver\Exception\Exception $e) {
    51 echo "Error: " . $e->getMessage() . "\n";
    52}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

php atlas-vector-search-quick-start.php
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.py.

  2. Copy and paste the following sample query into the atlas-vector-search-quick-start.py file:

    1import pymongo
    2
    3# connect to your cluster
    4client = pymongo.MongoClient("<connection-string>")
    5
    6# define pipeline
    7pipeline = [
    8 {
    9 '$vectorSearch': {
    10 'index': 'vector_index',
    11 'path': 'plot_embedding_voyage_3_large',
    12 'queryVector': [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234],
    13 'numCandidates': 150,
    14 'limit': 10
    15 }
    16 }, {
    17 '$project': {
    18 '_id': 0,
    19 'plot': 1,
    20 'title': 1,
    21 'score': {
    22 '$meta': 'vectorSearchScore'
    23 }
    24 }
    25 }
    26]
    27
    28# run pipeline
    29result = client["sample_mflix"]["embedded_movies"].aggregate(pipeline)
    30
    31# print results
    32for i in result:
    33 print(i)
    34

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

python atlas-vector-search-quick-start.py
1{'plot': 'At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.', 'title': 'About Time', 'score': 0.7710106372833252}
2{'plot': 'A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.', 'title': 'Retroactive', 'score': 0.760047972202301}
3{'plot': 'A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...', 'title': 'A.P.E.X.', 'score': 0.7576861381530762}
4{'plot': 'An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.', 'title': 'Timecop', 'score': 0.7576561570167542}
5{'plot': 'After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.', 'title': 'Back to the Future Part II', 'score': 0.7521393895149231}
6{'plot': 'A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.', 'title': 'Thrill Seekers', 'score': 0.7509932518005371}
7{'plot': 'Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...', 'title': 'Timerider: The Adventure of Lyle Swann', 'score': 0.7502642869949341}
8{'plot': 'Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.', 'title': 'The Time Machine', 'score': 0.7502503395080566}
9{'plot': 'A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.', 'title': "The Time Traveler's Wife", 'score': 0.749496340751648}
10{'plot': 'A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.', 'title': 'The Final Countdown', 'score': 0.7469133734703064}
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas_vector_search_quick_start.rb .

  2. Copy and paste the following sample query into the atlas_vector_search_quick_start.rb file:

    1require 'mongo'
    2require 'json'
    3
    4# Replace the placeholder with your Atlas connection string
    5uri = "<connection-string>"
    6
    7begin
    8 # Connect to the MongoDB client
    9 client = Mongo::Client.new(uri, database: 'sample_mflix')
    10
    11 # Set the namespace
    12 db = client.database
    13 collection = db[:embedded_movies]
    14
    15 # Define the pipeline with $vectorSearch query options
    16 pipeline = [
    17 {
    18 '$vectorSearch' => {
    19 'queryVector' => [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234],
    20 'index' => 'vector_index',
    21 'path' => 'plot_embedding_voyage_3_large',
    22 'numCandidates' => 150,
    23 'limit' => 10
    24 }
    25 },
    26 {
    27 '$project' => {
    28 '_id' => 0,
    29 'plot' => 1,
    30 'title' => 1,
    31 'score' => { '$meta' => 'vectorSearchScore' }
    32 }
    33 }
    34 ]
    35
    36 # Run the pipeline
    37 results = collection.aggregate(pipeline)
    38
    39 # Print results
    40 results.each do |document|
    41 puts JSON(document)
    42 end
    43
    44rescue Mongo::Error::NoServerAvailable => e
    45 puts "Failed to connect to MongoDB: #{e.message}"
    46
    47rescue Mongo::Error::OperationFailure => e
    48 puts "Failed to run aggregation: #{e.message}"
    49
    50rescue Mongo::Error => e
    51 puts "A MongoDB error occurred: #{e.message}"
    52
    53rescue StandardError => e
    54 puts "A general error occurred: #{e.message}"
    55
    56ensure
    57 client&.close
    58 puts "MongoDB client closed."
    59end

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

bundle exec ruby atlas_vector_search_quick_start.rb
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

For more detailed installation instructions, see the MongoDB Rust Driver documentation.

2

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. In the /src directory of your project, create a file named vector_search_query.rs.

  2. Copy and paste the following sample query into the vector_search_query.rs file:

    vector_search_query.rs
    1use mongodb::{
    2 bson::{Document, doc},
    3 Client
    4};
    5use futures::TryStreamExt;
    6
    7#[tokio::main]
    8pub(crate) async fn basic_query() -> mongodb::error::Result<()> {
    9 // Replace the placeholder with your Atlas connection string
    10 let client = Client::with_uri_str("<connection-string>").await?;
    11
    12 let pipeline = vec! [
    13 doc! {
    14 "$vectorSearch": doc! {
    15 "queryVector": [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234],
    16 "path": "plot_embedding_voyage_3_large",
    17 "numCandidates": 150,
    18 "index": "vector_index",
    19 "limit": 10
    20 }
    21 },
    22 doc! {
    23 "$project": doc! {
    24 "_id": 0,
    25 "plot": 1,
    26 "title": 1,
    27 "score": doc! { "$meta": "vectorSearchScore"
    28 }
    29 }
    30 }
    31 ];
    32 let coll = client.database("sample_mflix").collection::<Document>("embedded_movies");
    33 let mut results = coll.aggregate(pipeline).await?;
    34 while let Some(result) = results.try_next().await? {
    35 println!("{}", result);
    36 }
    37 Ok(())
    38}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4

Since the query vector is a large inline array, add the #![recursion_limit] attribute at the top of your main.rs file. This crate-level attribute and takes effect only in the crate root, not in the vector_search_query.rs module file.

#![recursion_limit = "2560"]
mod vector_search_query;
fn main() -> mongodb::error::Result<()> {
vector_search_query::basic_query()
}
5
cargo run
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

Create a file named VectorQuery.scala. Copy and paste the following code into the file.

VectorQuery.scala
1import org.mongodb.scala._
2import org.mongodb.scala.model._
3import org.mongodb.scala.model.search.SearchPath.fieldPath
4import org.mongodb.scala.model.search.VectorSearchOptions
5
6class VectorQuery {
7 def performVectorQuery() = {
8 val collection =
9 MongoClient("<connection-string>")
10 .getDatabase("sample_mflix")
11 .getCollection("embedded_movies")
12
13 val options: VectorSearchOptions = VectorSearchOptions.approximateVectorSearchOptions(150)
14
15 collection.aggregate(Seq(
16 Aggregates.vectorSearch(fieldPath("plot_embedding_voyage_3_large"),
17 List(-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234),
18 "vector_index",
19 10,
20 options
21 ),
22 Aggregates.project(
23 Projections.fields(
24 Projections.excludeId(),
25 Projections.include("plot"),
26 Projections.include("title"),
27 Projections.meta(
28 "score", "vectorSearchScore"
29 )
30 )
31 )
32 )).foreach { doc => println(doc.toBsonDocument()) }
33 }
34}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Create a class instance and call the function in your project's Main.scala file.

object Main extends App {
private val queryInstance = new VectorQuery
queryInstance.performVectorQuery()
}
4
sbt:quick-start> ~run
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1
  1. Create a file named query-embeddings.js to store the query embeddings.

  2. Copy and paste the following embeddings for the string time travel into the query-embeddings.js file.

    QUERY_EMBEDDING = [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234];
  3. Save the query-embeddings.js file.

2

In mongosh, run the following command, replacing <path-to-file> with the complete path to your query-embeddings.js file.

load('/<path-to-file>/query-embeddings.js')

You can verify if the file loaded properly by running the following command:

QUERY_EMBEDDING.length
2048
3

Copy and paste the following sample query into your terminal and then run it using mongosh.

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

1db.embedded_movies.aggregate([
2 {
3 "$vectorSearch": {
4 "index": "vector_index",
5 "path": "plot_embedding_voyage_3_large",
6 "queryVector": QUERY_EMBEDDING,
7 "numCandidates": 150,
8 "limit": 10
9 }
10 },
11 {
12 "$project": {
13 "_id": 0,
14 "plot": 1,
15 "title": 1,
16 "score": { $meta: "vectorSearchScore" }
17 }
18 }
19])
1[
2 {
3 plot: 'At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.',
4 title: 'About Time',
5 score: 0.7710106372833252
6 },
7 {
8 plot: 'A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.',
9 title: 'Retroactive',
10 score: 0.760047972202301
11 },
12 {
13 plot: 'A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...',
14 title: 'A.P.E.X.',
15 score: 0.7576861381530762
16 },
17 {
18 plot: 'An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.',
19 title: 'Timecop',
20 score: 0.7576561570167542
21 },
22 {
23 plot: 'After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.',
24 title: 'Back to the Future Part II',
25 score: 0.7521393895149231
26 },
27 {
28 plot: 'A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.',
29 title: 'Thrill Seekers',
30 score: 0.7509932518005371
31 },
32 {
33 plot: 'Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...',
34 title: 'Timerider: The Adventure of Lyle Swann',
35 score: 0.7502642869949341
36 },
37 {
38 plot: 'Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.',
39 title: 'The Time Machine',
40 score: 0.7502503395080566
41 },
42 {
43 plot: 'A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.',
44 title: "The Time Traveler's Wife",
45 score: 0.749496340751648
46 },
47 {
48 plot: 'A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.',
49 title: 'The Final Countdown',
50 score: 0.7469133734703064
51 }
52]

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.c and copy and paste the following sample query into the file:

    atlas-vector-search-quick-start.c
    1#include <bson/bson.h>
    2#include <mongoc/mongoc.h>
    3#include <stdio.h>
    4
    5int main(void) {
    6
    7 mongoc_client_t *client;
    8 mongoc_collection_t *collection;
    9 mongoc_cursor_t *cursor;
    10 bson_array_builder_t *builder;
    11 bson_t *pipeline;
    12 bson_t query_vector;
    13 bson_error_t error;
    14 const bson_t *doc;
    15 char *str;
    16
    17 int arrSize = 2048; // This collection has a vector array of 2048 dimensions; depending on your vector embedding model, this mary vary
    18 double embeddings[] = {-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234};
    19
    20 // Initialize the MongoDB C Driver
    21 mongoc_init();
    22
    23 // Connect to your Atlas collection
    24 client = mongoc_client_new("<connection-string>");
    25 collection = mongoc_client_get_collection (client, "sample_mflix", "embedded_movies");
    26
    27 // Build query vector array
    28 builder = bson_array_builder_new();
    29
    30 for(int i = 0; i < arrSize; i++){
    31 bson_array_builder_append_double(builder, embeddings[i]);
    32 }
    33
    34 bson_array_builder_build(builder, &query_vector);
    35 bson_array_builder_destroy(builder);
    36
    37 // Create aggregation pipeline for Vector Search
    38 pipeline = BCON_NEW(
    39 "pipeline",
    40 "[",
    41 "{",
    42 "$vectorSearch", "{",
    43 "index", "vector_index",
    44 "path", "plot_embedding_voyage_3_large",
    45 "queryVector", BCON_ARRAY(&query_vector),
    46 "numCandidates", BCON_INT32(150),
    47 "limit", BCON_INT32(10),
    48 "}",
    49 "}",
    50 "{",
    51 "$project", "{",
    52 "title", BCON_BOOL(true),
    53 "plot", BCON_BOOL(true),
    54 "_id", BCON_BOOL(false),
    55 "score", "{",
    56 "$meta", "vectorSearchScore",
    57 "}",
    58 "}",
    59 "}",
    60 "]"
    61 );
    62
    63 // Run query
    64 cursor = mongoc_collection_aggregate(collection, MONGOC_QUERY_NONE, pipeline, NULL, NULL );
    65
    66 // Print results
    67 while (mongoc_cursor_next (cursor, &doc)) {
    68 str = bson_as_canonical_extended_json (doc, NULL);
    69 printf ("%s\n", str);
    70 bson_free (str);
    71 }
    72
    73 // Cleanup
    74 bson_destroy(pipeline);
    75 mongoc_cursor_destroy(cursor);
    76 mongoc_collection_destroy(collection);
    77 mongoc_client_destroy(client);
    78 mongoc_cleanup();
    79
    80 return 0;
    81}

    This query uses the $vectorSearch stage to:

    • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

    • Consider up to the 150 most similar movie plots and return the top 10 results.

    It uses the $project stage to:

    • Only include the movie plot and title fields in the results.

    • Add a score field to show the relevance of each result to the search term.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3
  1. Replace the vector_index.c file name in your CMakeLists.txt file with your new atlas-vector-search-quick-start.c filename.

  2. Navigate to the /build directory, and prepare the project.

    cd build
    cmake ../
4

From your build directory, compile and run the atlas-vector-search-quick-start.c file.

cmake --build .
./atlas-vector-search-quick-start
1{ "plot" : "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title" : "About Time", "score" : { "$numberDouble" : "0.77101063728332519531" } }
2{ "plot" : "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title" : "Retroactive", "score" : { "$numberDouble" : "0.76004797220230102539" } }
3{ "plot" : "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title" : "A.P.E.X.", "score" : { "$numberDouble" : "0.75768613815307617188" } }
4{ "plot" : "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title" : "Timecop", "score" : { "$numberDouble" : "0.75765615701675415039" } }
5{ "plot" : "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title" : "Back to the Future Part II", "score" : { "$numberDouble" : "0.7521393895149230957" } }
6{ "plot" : "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title" : "Thrill Seekers", "score" : { "$numberDouble" : "0.75099325180053710938" } }
7{ "plot" : "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title" : "Timerider: The Adventure of Lyle Swann", "score" : { "$numberDouble" : "0.75026428699493408203" } }
8{ "plot" : "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title" : "The Time Machine", "score" : { "$numberDouble" : "0.75025033950805664062" } }
9{ "plot" : "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title" : "The Time Traveler's Wife", "score" : { "$numberDouble" : "0.74949634075164794922" } }
10{ "plot" : "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title" : "The Final Countdown", "score" : { "$numberDouble" : "0.74691337347030639648" } }
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas_vector_search_quick_start.cpp .

  2. Copy and paste the following sample query into the atlas_vector_search_quick_start.cpp file:

    atlas_vector_search_quick_start.cpp
    1#include <bsoncxx/builder/basic/document.hpp>
    2#include <bsoncxx/builder/list.hpp>
    3#include <bsoncxx/json.hpp>
    4#include <mongocxx/client.hpp>
    5#include <mongocxx/instance.hpp>
    6#include <mongocxx/uri.hpp>
    7
    8using bsoncxx::builder::basic::kvp;
    9using bsoncxx::builder::basic::make_document;
    10
    11int main() {
    12 try {
    13 mongocxx::instance inst{};
    14
    15 // Replace the placeholder with your Atlas connection string
    16 const auto uri = mongocxx::uri{"<connection-string>"};
    17
    18 // Connect to your cluster
    19 auto client = mongocxx::client{uri};
    20 auto db = client["sample_mflix"];
    21 auto collection = db["embedded_movies"];
    22
    23 // Define vector embeddings to search
    24 auto vectors = bsoncxx::builder::list{
    25 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234
    26 };
    27
    28 // Define the pipeline with vectorSearch query options
    29 mongocxx::pipeline stages;
    30
    31 stages
    32 .append_stage(make_document(
    33 kvp("$vectorSearch",
    34 make_document(kvp("index", "vector_index"),
    35 kvp("path", "plot_embedding_voyage_3_large"),
    36 kvp("queryVector", vectors),
    37 kvp("numCandidates", 150), kvp("limit", 10)))))
    38 .project(make_document(
    39 kvp("_id", 0), kvp("plot", 1), kvp("title", 1),
    40 kvp("score", make_document(kvp("$meta", "vectorSearchScore")))));
    41
    42 auto cursor = collection.aggregate(stages);
    43
    44 for (auto&& doc : cursor) {
    45 std::cout << bsoncxx::to_json(doc) << std::endl;
    46 }
    47 } catch (const std::exception& e) {
    48 std::cout << "Exception: " << e.what() << std::endl;
    49 }
    50 return 0;
    51}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3
  1. Replace the vector_index.cpp file name in your CMakeLists.txt file with your new atlas_vector_search_quick_start.cpp filename.

  2. Navigate to the /build directory, and prepare the project.

    cmake ../
  3. Build the app.

    cmake --build .
  4. Execute the app to run the query.

    ./query_quick_start
    1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
    2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
    3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
    4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
    5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
    6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
    7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
    8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
    9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
    10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a new file called DatabaseService.cs.

  2. Copy and paste the following sample query into the DatabaseService.cs file:

    DatabaseService.cs
    1namespace query_quick_start;
    2
    3using MongoDB.Bson;
    4using MongoDB.Bson.Serialization.Attributes;
    5using MongoDB.Bson.Serialization.Conventions;
    6using MongoDB.Driver;
    7
    8public class DatabaseService
    9{
    10 // Replace the placeholder with your Atlas connection string
    11 private const string MongoConnectionString = "<connection-string>";
    12
    13 public void RunVectorQuery(){
    14 var camelCaseConvention = new ConventionPack { new CamelCaseElementNameConvention() };
    15 ConventionRegistry.Register("CamelCase", camelCaseConvention, type => true);
    16
    17 // connect to your cluster
    18 var mongoClient = new MongoClient(MongoConnectionString);
    19
    20 // define namespace
    21 var moviesDatabase = mongoClient.GetDatabase("sample_mflix");
    22 var moviesCollection = moviesDatabase.GetCollection<EmbeddedMovie>("embedded_movies");
    23
    24 // define vector embeddings to search
    25 var vector = new[] {-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234};
    26 var options = new VectorSearchOptions<EmbeddedMovie>() {
    27 IndexName = "vector_index",
    28 NumberOfCandidates = 150
    29 };
    30
    31 // run query
    32 var results = moviesCollection.Aggregate()
    33 .VectorSearch(movie => movie.Embedding, vector, 10, options)
    34 .Project(Builders<EmbeddedMovie>.Projection
    35 .Include(movie => movie.Title)
    36 .Include(movie => movie.Plot)
    37 .Exclude(movie => movie.Id)
    38 .MetaVectorSearchScore(movie => movie.Score))
    39 .ToList();
    40
    41 // print results
    42 foreach (var movie in results)
    43 {
    44 Console.WriteLine(movie.ToJson());
    45 }
    46 }
    47}
    48
    49[BsonIgnoreExtraElements]
    50public class EmbeddedMovie
    51{
    52 [BsonIgnoreIfDefault]
    53 public ObjectId Id { get; set; }
    54 public string? Title { get; set; }
    55 public string? Plot { get; set; }
    56 [BsonElement("plot_embedding_voyage_3_large")]
    57 public double[]? Embedding { get; set; }
    58 public double Score { get; set; }
    59}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Remove the index creation code from your Program.cs file. Instead, initialize the DatabaseService object and call the method to run the query:

Program.cs
using query_quick_start;
var databaseService = new DatabaseService();
databaseService.RunVectorQuery();
4

Compile and run your project.

dotnet run query-quick-start.csproj
1{ "plot" : "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title" : "About Time", "score" : 0.7710106372833252 }
2{ "plot" : "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title" : "Retroactive", "score" : 0.76004797220230103 }
3{ "plot" : "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title" : "A.P.E.X.", "score" : 0.75768613815307617 }
4{ "plot" : "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title" : "Timecop", "score" : 0.75765615701675415 }
5{ "plot" : "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title" : "Back to the Future Part II", "score" : 0.7521393895149231 }
6{ "plot" : "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title" : "Thrill Seekers", "score" : 0.75099325180053711 }
7{ "plot" : "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title" : "Timerider: The Adventure of Lyle Swann", "score" : 0.75026428699493408 }
8{ "plot" : "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title" : "The Time Machine", "score" : 0.75025033950805664 }
9{ "plot" : "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title" : "The Time Traveler's Wife", "score" : 0.74949634075164795 }
10{ "plot" : "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title" : "The Final Countdown", "score" : 0.7469133734703064 }
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named BasicQuery.java.

  2. Copy and paste the following sample query into the BasicQuery.java file:

    1import com.mongodb.client.MongoClient;
    2import com.mongodb.client.MongoClients;
    3import com.mongodb.client.MongoCollection;
    4import com.mongodb.client.MongoDatabase;
    5import com.mongodb.client.model.search.FieldSearchPath;
    6import org.bson.Document;
    7import org.bson.conversions.Bson;
    8
    9import java.util.List;
    10
    11import static com.mongodb.client.model.Aggregates.project;
    12import static com.mongodb.client.model.Aggregates.vectorSearch;
    13import static com.mongodb.client.model.Projections.fields;
    14import static com.mongodb.client.model.Projections.include;
    15import static com.mongodb.client.model.Projections.exclude;
    16import static com.mongodb.client.model.Projections.metaVectorSearchScore;
    17import static com.mongodb.client.model.search.SearchPath.fieldPath;
    18import static com.mongodb.client.model.search.VectorSearchOptions.approximateVectorSearchOptions;
    19import static java.util.Arrays.asList;
    20
    21public class BasicQuery {
    22 public static void main( String[] args ) {
    23 // specify connection
    24 String uri = "<connection-string>";
    25
    26 // establish connection and set namespace
    27 try (MongoClient mongoClient = MongoClients.create(uri)) {
    28 MongoDatabase database = mongoClient.getDatabase("sample_mflix");
    29 MongoCollection<Document> collection = database.getCollection("embedded_movies");
    30
    31
    32 // define $vectorSearch query options
    33 List<Double> queryVector = (asList(-0.034731735d,0.008558298d,-0.0153717d,-0.029912498d,0.011549547d,0.010261648d,-0.011964999d,-0.023265276d,0.010303194d,-0.006896493d,-0.00054528d,0.003926015d,-0.025757983d,0.027419789d,0.001199616d,-0.036227357d,-0.005297005d,0.021935832d,0.010303194d,-0.019193852d,0.025093261d,-0.040049512d,-0.033900831d,-0.011466458d,-0.01827986d,-0.0153717d,0.023265276d,0.007727395d,0.000114249d,0.005317777d,-0.043871664d,-0.02127111d,-0.019609304d,0.016368784d,-0.004756918d,0.003552109d,0.006522586d,-0.005400868d,-0.015620971d,-0.034565553d,-0.018695312d,-0.023099095d,0.050851244d,-0.034731735d,0.004819236d,0.022268193d,-0.095719993d,0.05517194d,-0.046198189d,-0.036393538d,0.007187308d,-0.02459472d,-0.036725901d,0.009472291d,0.019027673d,0.020938748d,-0.011051006d,0.027087428d,0.04586583d,-0.022600554d,-0.05517194d,0.044204023d,0.01213118d,0.047859997d,-0.03938479d,0.002928932d,0.002056484d,0.019443123d,-0.028583053d,0.013543714d,0.022932915d,0.011632638d,0.004923099d,0.000389486d,0.020024756d,-0.024096178d,-0.022766734d,0.011217186d,-0.003198975d,0.007104218d,-0.047195274d,-0.013377533d,0.013294443d,0.024096178d,-0.056501385d,-0.026755067d,-0.008433662d,-0.001911076d,0.007976666d,-0.008101301d,-0.014042255d,0.008641388d,-0.02176965d,0.010012378d,-0.000607598d,-0.024927082d,0.024927082d,-0.018612221d,-0.001184036d,0.005567048d,0.001324251d,-0.019526213d,-0.023597637d,0.060489718d,-0.010178559d,-0.019609304d,0.004112968d,-0.011217186d,-0.031574301d,-0.008766023d,0.005483958d,-0.061819162d,-0.023431456d,-0.040714234d,0.015039339d,0.026422706d,0.016202603d,0.004653055d,0.041046593d,-0.018030589d,0.040381871d,-0.002638116d,0.013045172d,0.004216831d,0.005650138d,0.027419789d,0.003926015d,-0.028749233d,0.004798463d,-0.030244859d,0.063813329d,0.007145763d,-0.017448956d,0.025591804d,-0.045201108d,0.010718645d,0.002804297d,0.014291527d,0.04586583d,-0.015205519d,-0.021603471d,-0.035230275d,0.00760276d,0.033236109d,0.016534964d,-0.043206941d,-0.003115885d,-0.026256526d,0.005940954d,0.016534964d,0.024262359d,-0.001630647d,0.028084511d,-0.012795902d,0.007270399d,0.001381376d,-0.009763107d,-0.006896493d,0.008433662d,-0.019360034d,0.000386889d,0.030411039d,0.025591804d,0.010469374d,0.037722982d,-0.001147684d,-0.005400868d,0.052845411d,-0.052513052d,0.00768585d,-0.004299921d,0.00922302d,0.011881908d,0.012962082d,-0.068798743d,0.003593654d,0.020938748d,-0.013792985d,-0.034565553d,-0.007519669d,-0.04021569d,-0.020689478d,0.006273315d,0.046862911d,0.006107135d,0.002638116d,-0.013792985d,-0.005400868d,-0.020274026d,0.007644305d,-0.010801735d,0.026422706d,0.043871664d,0.003780607d,0.010261648d,-0.064145692d,0.011881908d,-0.009056839d,0.009347656d,-0.02459472d,0.026422706d,0.033236109d,0.041212775d,0.019027673d,-0.00315743d,0.004424557d,0.020689478d,-0.0153717d,-0.015205519d,-0.034897912d,0.020274026d,0.016867325d,0.040714234d,-0.022766734d,-0.010967916d,0.026256526d,0.007062673d,-0.015953332d,-0.007727395d,0.031574301d,-0.002887387d,-0.00614868d,0.004569965d,0.019027673d,0.012878992d,0.011798819d,0.004258377d,-0.019193852d,-0.021437289d,-0.021603471d,0.000301202d,-0.051183607d,-0.004985416d,-0.030078677d,0.012629721d,0.065142773d,-0.031740483d,-0.021104928d,-0.03938479d,-0.003365156d,-0.016036423d,0.036393538d,0.009804652d,-0.018612221d,0.060489718d,-0.003697517d,0.000547876d,0.063480966d,0.02758597d,0.010053922d,-0.003655972d,-0.001485239d,0.018362951d,0.021104928d,-0.003905243d,0.019443123d,-0.002658889d,-0.00380138d,-0.013626805d,0.035894997d,0.035396457d,-0.005691683d,0.002762751d,0.012878992d,-0.009596926d,-0.009970833d,-0.015953332d,0.022434372d,0.00614868d,-0.021188019d,0.001557943d,-0.020190936d,0.009763107d,0.017448956d,0.006730312d,0.005567048d,0.019692395d,-0.00218112d,-0.016867325d,0.006854947d,0.007976666d,0.019193852d,0.040880412d,0.007353489d,-0.02127111d,-0.031906664d,-0.026755067d,-0.017947499d,0.040381871d,0.042209856d,0.00913993d,-0.0307434d,-0.017781317d,-0.015039339d,0.03057722d,0.017532047d,0.0187784d,-0.060822077d,0.002928932d,-0.026422706d,-0.005899409d,0.039717149d,0.026588887d,-0.000971118d,0.004923099d,-0.013626805d,0.0187784d,-0.031408124d,-0.000695881d,0.050851244d,-0.014457707d,-0.007311944d,-0.001293092d,-0.002139574d,-0.019276943d,0.00290816d,0.019360034d,-0.017781317d,0.002160347d,0.016618054d,-0.006522586d,0.011798819d,0.029247776d,-0.02775215d,0.010344739d,-0.018362951d,-0.036725901d,-0.015870241d,0.015704062d,-0.012463541d,0.02459472d,-0.024096178d,0.001152877d,-0.031408124d,0.025425622d,0.027087428d,0.00922302d,0.034565553d,0.015704062d,-0.020689478d,-0.00517237d,-0.014706978d,-0.001589101d,0.026090344d,0.014956249d,0.011715728d,0.004299921d,-0.00913993d,0.022434372d,-0.03705826d,0.048524719d,-0.030411039d,0.008433662d,0.017033506d,-0.000511525d,-0.031408124d,0.005940954d,-0.012962082d,-0.031574301d,0.017448956d,0.010178559d,-0.011383367d,-0.020107845d,-0.005151597d,0.006647222d,0.013128263d,0.007145763d,0.008059756d,-0.045201108d,-0.004943871d,0.015787151d,-0.045201108d,-0.020772567d,-0.020274026d,0.028250692d,-0.024262359d,-0.004424557d,0.009804652d,0.000472576d,-0.005691683d,0.001443693d,-0.013294443d,0.001412535d,0.013211353d,-0.01213118d,-0.002118802d,0.017781317d,-0.007353489d,-0.031075761d,-0.004923099d,0.011383367d,-0.004486875d,-0.010178559d,0.016618054d,0.014457707d,0.023763817d,-0.02459472d,-0.00388447d,0.012546631d,-0.007519669d,0.015704062d,-0.014291527d,0.009680017d,-0.035562634d,0.023763817d,0.053510133d,-0.0555043d,-0.003572882d,0.022102011d,0.021603471d,-0.017282777d,-0.001474852d,-0.043539301d,0.007810486d,-0.025757983d,-0.005400868d,0.029912498d,-0.00760276d,0.014125346d,0.030909581d,-0.03340229d,-0.009680017d,0.018030589d,0.008849114d,0.03057722d,0.019775484d,0.014125346d,0.031906664d,-0.03057722d,-0.027087428d,-0.023597637d,-0.022434372d,-0.012878992d,0.016285693d,-0.021603471d,-0.029746316d,0.029746316d,0.020357117d,0.006314861d,-0.001158071d,0.028749233d,-0.045201108d,0.011383367d,0.011134096d,-0.021437289d,-0.035728816d,0.001827986d,0.008267482d,-0.057498466d,0.01213118d,-0.01213118d,-0.040548053d,0.010718645d,0.004798463d,-0.004881553d,-0.019526213d,-0.008558298d,0.0059825d,-0.000262254d,-0.017615138d,0.005193142d,0.019692395d,-0.00198378d,-0.002845842d,0.012546631d,0.006107135d,-0.008225936d,-0.008890659d,0.015870241d,0.00517237d,0.002596571d,-0.010427829d,-0.019110762d,0.024262359d,0.012048089d,-0.032405205d,0.006522586d,0.013211353d,0.013211353d,-0.038221523d,-0.007727395d,-0.008267482d,-0.019276943d,0.001474852d,0.031408124d,-0.035562634d,0.017532047d,-0.023431456d,-0.015454791d,-0.011383367d,0.016534964d,-0.02176965d,0.008682934d,0.027253609d,0.020190936d,-0.0247609d,-0.007311944d,0.009555381d,-0.01852913d,-0.011632638d,0.011549547d,0.027419789d,-0.034067012d,-0.01229736d,0.0307434d,0.003946788d,0.0046946d,0.037722982d,0.03057722d,-0.010427829d,0.002284982d,0.033236109d,0.030078677d,-0.013377533d,0.007395034d,-0.012048089d,0.040714234d,-0.028749233d,-0.000102565d,-0.0059825d,-0.041046593d,0.017698228d,-0.006356406d,0.003178203d,0.009056839d,0.023099095d,0.00606559d,0.011881908d,-0.02127111d,-0.001126912d,-0.027087428d,0.011134096d,0.001204809d,-0.017033506d,0.011051006d,-0.014374617d,0.017864408d,0.023431456d,-0.002077257d,-0.026755067d,-0.043871664d,0.025757983d,-0.006190225d,0.001152877d,0.011798819d,-0.024262359d,0.006564131d,-0.070128188d,-0.004362239d,0.012962082d,-0.013626805d,-0.001402148d,-0.012214269d,0.011217186d,-0.015953332d,0.015787151d,0.011134096d,0.027253609d,0.024262359d,-0.048192356d,0.009970833d,0.018944582d,-0.00517237d,0.021935832d,0.02775215d,0.003406701d,-0.010884825d,0.075113602d,-0.015953332d,0.007727395d,0.026755067d,-0.006190225d,-0.012712811d,0.013377533d,0.005940954d,-0.008309027d,0.02459472d,0.002316141d,-0.022434372d,-0.012712811d,0.03057722d,-0.015787151d,0.026755067d,-0.001069787d,0.03988333d,-0.003697517d,0.039550968d,-0.019027673d,-0.0059825d,-0.00031029d,-0.012546631d,-0.003614427d,0.007478124d,0.005525503d,0.032571387d,-0.011798819d,-0.011466458d,-0.00606559d,-0.011798819d,0.018446039d,0.007976666d,0.018944582d,-0.02176965d,0.026588887d,-0.006273315d,-0.012463541d,-0.007395034d,0.012048089d,-0.029247776d,0.015454791d,-0.007145763d,0.006481041d,-0.015620971d,-0.00388447d,-0.025757983d,-0.001651419d,-0.032903746d,-0.005068507d,0.03938479d,0.003926015d,0.004715373d,0.022600554d,-0.012546631d,0.022932915d,0.007810486d,0.040714234d,0.019941665d,0.013543714d,0.003406701d,0.010884825d,-0.03988333d,0.042209856d,-0.022766734d,0.027419789d,-0.029580137d,0.043206941d,0.022932915d,0.021104928d,-0.056833744d,0.005193142d,0.036061179d,-0.012878992d,0.008516753d,-0.02758597d,-0.030244859d,-0.011798819d,0.001111332d,-0.014125346d,-0.014125346d,0.019027673d,0.029081594d,0.018861491d,0.013626805d,0.06846638d,0.023099095d,0.041378956d,0.001599488d,-0.028749233d,0.017781317d,0.016285693d,0.021603471d,-0.018113678d,0.011300277d,-0.032239024d,0.022434372d,-0.02459472d,-0.013626805d,0.005483958d,0.013460624d,-0.031574301d,-0.015620971d,0.016451873d,0.014790068d,-0.008849114d,0.011134096d,0.00461151d,0.015122429d,0.036227357d,0.00206687d,0.000877641d,0.022102011d,-0.028250692d,0.022600554d,-0.026422706d,0.004029878d,-0.032072846d,0.017116595d,0.010884825d,0.019609304d,0.00614868d,0.005733229d,0.016119512d,0.002866614d,-0.014540797d,0.012463541d,-0.003905243d,0.003759835d,-0.000485559d,-0.022766734d,-0.016285693d,0.037722982d,0.009513836d,0.001506011d,0.011964999d,0.004029878d,0.019941665d,-0.000965924d,0.002129188d,0.015205519d,0.071125269d,0.022932915d,0.005940954d,-0.00044661d,0.010220103d,-0.03423319d,-0.016285693d,-0.016867325d,-0.000659529d,-0.008018211d,-0.011383367d,0.000016634d,0.004071423d,-0.029413955d,0.019941665d,-0.00913993d,-0.024096178d,0.010635555d,0.010594009d,0.001547556d,0.036227357d,-0.030078677d,0.020772567d,0.022268193d,-0.014125346d,0.008766023d,-0.012962082d,-0.007187308d,0.017033506d,-0.007187308d,-0.015205519d,-0.005608593d,0.044536386d,-0.001235968d,0.007852031d,0.001599488d,0.005857864d,-0.005940954d,-0.010510919d,-0.005567048d,0.006730312d,0.016285693d,-0.010801735d,-0.024428539d,0.015122429d,-0.02176965d,0.01528861d,-0.007436579d,0.00226421d,-0.004715373d,0.004507647d,0.004341467d,0.005525503d,-0.031075761d,-0.005899409d,0.037556801d,0.014873158d,-0.000342747d,0.009970833d,-0.019443123d,0.023597637d,-0.012048089d,-0.025259443d,0.006024044d,-0.01827986d,0.010012378d,0.016784234d,0.013211353d,-0.005400868d,-0.024428539d,-0.02176965d,-0.035230275d,0.009347656d,0.028583053d,-0.015704062d,-0.017781317d,0.00226421d,0.001199616d,-0.003385928d,0.008267482d,0.002326528d,0.022434372d,-0.020190936d,-0.015787151d,0.000789358d,0.031241942d,0.011300277d,0.001506011d,-0.023265276d,-0.010967916d,0.009056839d,0.011300277d,-0.030244859d,0.007478124d,0.001111332d,-0.035894997d,0.0153717d,0.002700434d,0.021104928d,0.010884825d,-0.003344383d,0.00768585d,0.010386284d,0.00452842d,-0.014706978d,0.028084511d,0.013377533d,0.014873158d,0.046862911d,-0.015454791d,0.021188019d,0.013959166d,0.012629721d,0.025924165d,-0.018695312d,-0.00922302d,-0.0093892d,0.007727395d,0.036892079d,0.007228854d,-0.01229736d,0.029247776d,-0.004943871d,-0.027253609d,-0.008433662d,0.043206941d,0.002825069d,0.028583053d,-0.023431456d,0.034897912d,-0.041545134d,-0.016534964d,0.003053567d,-0.012712811d,0.002741979d,-0.007187308d,-0.025093261d,-0.045201108d,-0.004424557d,-0.016618054d,-0.008890659d,0.008018211d,-0.05184833d,-0.019526213d,-0.013377533d,-0.010469374d,0.030244859d,-0.005068507d,0.051183607d,0.005483958d,-0.006024044d,0.035064094d,-0.011134096d,0.014956249d,0.002284982d,0.001724123d,-0.01229736d,0.012629721d,0.010261648d,0.014540797d,0.048857078d,-0.029580137d,-0.024927082d,-0.008350573d,-0.03988333d,0.000939959d,0.013543714d,0.013626805d,-0.021437289d,-0.012962082d,0.006771857d,0.013709894d,-0.0059825d,0.035396457d,-0.006439496d,-0.029580137d,0.0046946d,0.019609304d,-0.007270399d,0.014291527d,-0.015620971d,0.00118923d,-0.00760276d,-0.017199686d,0.023265276d,0.026588887d,-0.030078677d,-0.016701145d,-0.025757983d,0.004964644d,0.026588887d,0.043206941d,0.011051006d,-0.009846197d,0.028915415d,0.031574301d,0.023763817d,0.009264565d,-0.008433662d,-0.035064094d,-0.000579035d,-0.0247609d,0.014125346d,0.016618054d,0.028749233d,-0.052513052d,-0.016867325d,-0.01238045d,0.002741979d,0.013709894d,0.010718645d,0.013626805d,0.009596926d,-0.004403784d,-0.02758597d,-0.000945152d,0.000420645d,0.003759835d,0.012546631d,-0.011881908d,0.008392117d,0.012795902d,0.005483958d,-0.009763107d,0.006397951d,-0.010801735d,0.012795902d,-0.03938479d,0.005733229d,0.005733229d,-0.000433627d,0.015454791d,0.002357686d,-0.006564131d,0.030244859d,-0.024428539d,0.016036423d,0.014291527d,-0.004964644d,0.029413955d,0.040381871d,0.012629721d,-0.033568468d,-0.026422706d,-0.037889164d,-0.034399372d,-0.03423319d,0.021935832d,0.004133741d,-0.014623888d,-0.013543714d,-0.05517194d,0.004736145d,0.006314861d,0.00006037d,0.006356406d,0.003323611d,-0.010344739d,0.007062673d,0.005899409d,-0.00623177d,-0.001973394d,-0.0555043d,0.011881908d,0.001350217d,-0.033069927d,-0.026921248d,0.022268193d,0.028583053d,-0.021021837d,0.010884825d,0.019692395d,-0.005442413d,0.031574301d,-0.014956249d,0.01238045d,-0.006356406d,0.006273315d,-0.003095113d,-0.014540797d,-0.02176965d,0.005006189d,-0.002658889d,0.042542219d,-0.02176965d,0.017199686d,-0.016701145d,-0.001599488d,0.016950415d,-0.021188019d,0.017864408d,0.023763817d,-0.000669915d,0.025093261d,0.021104928d,0.008807569d,0.037390623d,-0.025591804d,-0.003178203d,-0.001319058d,0.020523297d,0.005255459d,0.019276943d,-0.00226421d,0.00760276d,-0.057166107d,-0.006896493d,-0.034067012d,0.043871664d,0.038221523d,0.008101301d,0.03988333d,0.015870241d,0.000955538d,-0.004299921d,-0.002928932d,-0.002118802d,-0.020523297d,-0.001168457d,-0.011134096d,-0.000685495d,0.003323611d,0.011549547d,0.034565553d,0.029247776d,-0.029746316d,0.005213914d,0.019110762d,-0.003302838d,0.026422706d,0.028915415d,-0.036227357d,0.033236109d,0.038387705d,-0.035230275d,0.004071423d,-0.021935832d,0.002928932d,0.000976311d,0.000527104d,-0.006854947d,-0.003822153d,-0.001199616d,0.019858574d,-0.002762751d,0.039052427d,-0.008641388d,0.032239024d,-0.002295369d,0.035396457d,0.044536386d,-0.029413955d,0.025093261d,-0.03423319d,-0.016867325d,-0.008849114d,0.008433662d,-0.004486875d,0.017033506d,0.006730312d,-0.008599843d,-0.008225936d,-0.024428539d,0.006564131d,-0.007561215d,-0.032072846d,-0.019941665d,0.035396457d,0.019276943d,0.010261648d,0.005857864d,0.032239024d,-0.044204023d,-0.018944582d,0.002409618d,0.032903746d,0.05517194d,-0.03655972d,0.007976666d,0.030909581d,-0.023929998d,0.016368784d,0.01528861d,-0.00768585d,0.02176965d,0.013626805d,-0.02459472d,0.04021569d,-0.032737568d,0.006854947d,-0.011383367d,0.014873158d,-0.02176965d,0.00243039d,0.0093892d,0.0093892d,-0.029580137d,0.019858574d,0.01827986d,0.024428539d,0.017864408d,-0.028250692d,-0.001111332d,0.056169022d,0.007478124d,-0.010718645d,0.041046593d,-0.015704062d,0.034731735d,0.002523867d,-0.032571387d,0.004341467d,-0.023597637d,-0.011881908d,-0.035562634d,0.006688767d,0.007810486d,-0.012712811d,0.022600554d,0.03057722d,0.022600554d,0.010552464d,0.0307434d,-0.009638472d,0.02176965d,-0.018030589d,0.024262359d,-0.036227357d,-0.020772567d,0.001641033d,-0.022932915d,-0.014623888d,0.018362951d,0.002575798d,0.006190225d,-0.011051006d,0.021021837d,0.019110762d,0.02127111d,-0.028583053d,-0.052180689d,-0.014291527d,-0.010552464d,0.036393538d,0.042542219d,-0.04586583d,-0.001869531d,0.008350573d,-0.008516753d,-0.020772567d,0.000294711d,0.015704062d,-0.014457707d,-0.020772567d,0.008766023d,-0.026588887d,-0.004736145d,-0.028084511d,-0.007519669d,0.010552464d,-0.016534964d,0.006190225d,0.012962082d,-0.016618054d,0.012546631d,0.02459472d,0.022932915d,0.020440206d,-0.027918331d,-0.008059756d,0.020689478d,-0.014623888d,-0.011466458d,-0.006896493d,-0.020024756d,-0.031408124d,0.021603471d,0.007270399d,-0.03057722d,0.008350573d,-0.021437289d,0.00072704d,-0.043871664d,0.006314861d,-0.017199686d,0.02176965d,0.024262359d,-0.020357117d,-0.000542683d,-0.005213914d,0.001963008d,-0.00064395d,-0.022434372d,0.022102011d,-0.006688767d,-0.028583053d,0.002191506d,-0.005047734d,0.002368073d,0.014956249d,0.023929998d,-0.003302838d,-0.032239024d,0.022268193d,-0.013377533d,-0.010801735d,0.003676744d,0.009015295d,-0.039550968d,0.010884825d,-0.033568468d,0.013709894d,-0.029413955d,-0.006356406d,-0.020274026d,0.023597637d,0.030909581d,0.02176965d,0.016285693d,0.045533467d,-0.024096178d,-0.030909581d,-0.026422706d,0.002783524d,-0.010594009d,0.004362239d,-0.070792913d,0.009472291d,-0.022102011d,0.011134096d,-0.017448956d,-0.011549547d,-0.056833744d,0.00082571d,0.026588887d,-0.013709894d,0.002575798d,0.02176965d,-0.000568649d,-0.007270399d,0.004279149d,-0.042874578d,-0.026588887d,0.016784234d,0.036725901d,-0.028915415d,-0.009513836d,0.017448956d,0.002035712d,-0.007228854d,0.011383367d,0.011134096d,0.028915415d,0.0153717d,-0.027087428d,0.043871664d,-0.005089279d,0.006314861d,0.014291527d,-0.003240521d,0.025924165d,-0.001230775d,-0.015454791d,-0.012629721d,0.031740483d,-0.039717149d,-0.031075761d,0.006605676d,-0.008641388d,-0.032239024d,0.037722982d,-0.03705826d,-0.024096178d,0.001911076d,0.018196769d,-0.007353489d,-0.011300277d,-0.029081594d,0.004590738d,-0.018030589d,-0.026588887d,0.010261648d,0.038221523d,0.008392117d,-0.01213118d,0.018362951d,-0.034731735d,-0.017781317d,-0.011632638d,0.005255459d,0.000851675d,0.014208436d,-0.000039922d,-0.000228498d,0.014790068d,0.00913993d,0.0004544d,-0.011798819d,-0.020440206d,0.005899409d,0.008350573d,0.006314861d,0.040548053d,0.003427474d,-0.010801735d,0.008599843d,0.002586185d,-0.041212775d,-0.016368784d,0.020024756d,0.000965924d,-0.021021837d,-0.008475208d,0.0307434d,0.00760276d,0.003614427d,0.003489791d,-0.025924165d,0.000799744d,0.013460624d,-0.020440206d,0.048857078d,0.004320694d,-0.048857078d,0.015039339d,-0.029580137d,0.025924165d,0.018861491d,-0.014706978d,0.000576439d,-0.031241942d,0.0307434d,0.0153717d,0.014706978d,0.028084511d,-0.01238045d,-0.031241942d,0.018196769d,-0.034897912d,0.008142847d,0.010718645d,0.00922302d,0.047859997d,-0.00072704d,-0.010427829d,0.007104218d,0.026256526d,0.012214269d,-0.013377533d,-0.05184833d,0.005276232d,0.021935832d,-0.007021128d,0.009804652d,0.007893575d,0.024096178d,-0.002357686d,0.033900831d,-0.031740483d,0.034565553d,-0.036892079d,-0.015454791d,0.030411039d,0.010552464d,-0.022268193d,-0.001391762d,-0.008184392d,-0.008558298d,0.008475208d,-0.009929287d,0.010427829d,0.041378956d,-0.009555381d,-0.008724478d,-0.039052427d,0.034731735d,-0.014291527d,0.023099095d,0.029081594d,0.007519669d,0.010967916d,-0.008142847d,0.006190225d,-0.031075761d,0.033734649d,-0.001672192d,0.047859997d,-0.022434372d,-0.007395034d,0.01213118d,0.056169022d,0.002762751d,-0.029413955d,-0.000763392d,-0.015787151d,0.010801735d,0.008142847d,0.029912498d,-0.0018176d,0.033236109d,-0.046198189d,-0.002492708d,-0.006730312d,0.008807569d,-0.03655972d,0.009430746d,-0.053842496d,-0.060489718d,0.046862911d,0.002783524d,-0.0187784d,0.000571246d,0.00760276d,0.002482322d,0.001319058d,-0.014291527d,0.001464466d,-0.011632638d,-0.012463541d,-0.004902326d,0.000841289d,0.006688767d,0.030244859d,0.018944582d,0.000532297d,-0.015620971d,0.007104218d,0.005608593d,0.002035712d,-0.023763817d,0.003032795d,0.010594009d,-0.023597637d,-0.042376038d,-0.005255459d,0.001199616d,-0.0247609d,-0.007893575d,-0.011632638d,0.013045172d,-0.005691683d,-0.007104218d,0.027419789d,-0.004320694d,-0.005525503d,-0.026090344d,0.031408124d,-0.012795902d,-0.007062673d,0.000939959d,0.000030185d,0.004175286d,0.014291527d,0.033236109d,-0.038720068d,0.074116521d,-0.019692395d,0.001589101d,0.013792985d,-0.056169022d,-0.028749233d,-0.001599488d,0.004175286d,0.014790068d,0.00162026d,-0.007519669d,-0.041378956d,0.016534964d,-0.003572882d,-0.002575798d,-0.019526213d,-0.00922302d,-0.033900831d,-0.042043675d,-0.014208436d,0.010178559d,0.017698228d,0.032239024d,0.00913993d,0.009264565d,-0.012463541d,-0.005857864d,-0.015870241d,0.004486875d,0.018861491d,-0.000176567d,-0.029912498d,0.016784234d,0.012546631d,0.051183607d,0.023597637d,0.032903746d,0.0153717d,-0.013377533d,-0.000016634d,-0.061486799d,-0.034565553d,0.016119512d,0.00380138d,-0.003863698d,0.004362239d,-0.017532047d,-0.002762751d,0.000102565d,-0.021437289d,0.029247776d,-0.010718645d,-0.015870241d,-0.016285693d,0.010220103d,-0.000373906d,0.012962082d,0.010137013d,-0.007228854d,0.02127111d,-0.029247776d,0.018113678d,0.009181475d,0.002233051d,0.014374617d,-0.00396756d,0.010801735d,0.007644305d,0.020855658d,0.014790068d,0.032737568d,-0.037390623d,0.003032795d,0.010801735d,-0.01553788d,-0.014790068d,0.019526213d,-0.017947499d,-0.007893575d,-0.011964999d,-0.00614868d,-0.005857864d,-0.032072846d,-0.025924165d,0.001163264d,-0.013294443d,-0.01553788d,0.016701145d,-0.013460624d,-0.001111332d,0.00760276d,0.01553788d,-0.033734649d,0.048192356d,-0.003282066d,0.031906664d,0.002845842d,0.003240521d,0.017116595d,-0.01827986d,0.006896493d,-0.00760276d,-0.009680017d,-0.02459472d,-0.020689478d,-0.053510133d,0.00614868d,-0.010552464d,-0.032405205d,-0.0307434d,0.025093261d,0.003635199d,-0.008101301d,-0.00606559d,-0.007436579d,0.00606559d,-0.012962082d,0.026921248d,0.009098385d,0.046530552d,-0.011632638d,0.032571387d,-0.033900831d,0.009846197d,0.002866614d,0.032903746d,0.008973749d,0.012712811d,0.040049512d,0.013626805d,-0.026256526d,-0.031408124d,0.036227357d,0.011964999d,-0.006024044d,-0.001848759d,0.015704062d,-0.021188019d,-0.035064094d,-0.013377533d,-0.009721561d,-0.01553788d,0.008766023d,0.005400868d,0.004507647d,-0.018362951d,-0.026588887d,-0.00913993d,-0.025591804d,0.035894997d,0.021935832d,-0.031906664d,-0.000602404d,0.026422706d,-0.006397951d,0.006647222d,0.0093892d,0.020606387d,0.00913993d,0.015620971d,-0.024096178d,0.00063616d,-0.006564131d,0.01238045d,-0.013709894d,0.000563456d,-0.009887742d,0.016618054d,-0.003323611d,0.000451803d,0.001609874d,0.008682934d,0.025259443d,0.020024756d,-0.027253609d,0.010884825d,0.028250692d,-0.054839578d,0.033568468d,-0.004902326d,0.003053567d,0.020274026d,-0.015704062d,-0.00614868d,-0.063813329d,0.002482322d,0.009763107d,-0.001609874d,-0.012214269d,0.020107845d,0.001921462d,0.018695312d,-0.004923099d,0.007270399d,-0.023763817d,0.005234687d,0.003406701d,0.002565412d,0.007104218d,0.000841289d,0.016202603d,0.01827986d,-0.031075761d,-0.035562634d,-0.025259443d,-0.007021128d,0.000641353d,-0.033069927d,0.010718645d,0.005650138d,0.024927082d,-0.002658889d,0.00380138d,0.009929287d,-0.004258377d,-0.039717149d,-0.022434372d,0.025425622d,0.00198378d,0.006356406d,0.017615138d,-0.032072846d,0.046862911d,-0.026921248d,0.005940954d,0.021603471d,-0.002253824d,0.002825069d,-0.030411039d,-0.003115885d,0.023597637d,-0.004320694d,-0.007852031d,0.018030589d,-0.008724478d,-0.005733229d,0.032903746d,0.013876075d,0.015454791d,-0.023597637d,0.005151597d,-0.035396457d,0.02176965d,-0.012463541d,0.025591804d,0.014540797d,-0.027918331d,0.004154514d,0.008724478d,0.016036423d,-0.015870241d,0.005400868d,-0.017365867d,-0.044868745d,-0.000485559d,0.020357117d,-0.00760276d,-0.023265276d,-0.012048089d,0.008433662d,0.018362951d,-0.006979583d,0.0307434d,0.008392117d,0.027087428d,-0.019360034d,0.016119512d,0.02127111d,0.010801735d,0.00299125d,0.002949705d,0.012463541d,-0.000025966d,0.015953332d,0.029413955d,0.020024756d,0.003780607d,0.022102011d,-0.031740483d,0.01553788d,0.010386284d,0.028749233d,-0.010884825d,0.008682934d,-0.003531337d,-0.05517194d,-0.019360034d,-0.009347656d,-0.002025325d,0.003261293d,-0.025425622d,-0.01553788d,-0.000251867d,0.014291527d,0.012546631d,0.035728816d,-0.007062673d,-0.006605676d,0.000384293d,-0.005047734d,-0.032571387d,-0.021188019d,-0.02127111d,-0.016036423d,0.008475208d,-0.004009106d,0.014291527d,-0.008101301d,0.004424557d,-0.038221523d,-0.019360034d,0.015039339d,-0.015454791d,-0.029580137d,0.035728816d,0.004466102d,-0.000778971d,-0.005068507d,-0.017781317d,0.00477769d,0.001838372d,0.030244859d,0.01213118d,-0.022932915d,-0.005359322d,0.037390623d,0.005899409d,0.002046098d,0.037889164d,0.016701145d,0.010303194d,0.02127111d,-0.009513836d,-0.022268193d,-0.005650138d,-0.00388447d,0.016534964d,-0.023265276d,-0.00054528d,0.004819236d,0.004715373d,-0.001178843d,-0.051183607d,-0.00614868d,-0.010552464d,-0.002741979d,-0.009181475d,0.023597637d,0.019193852d,0.017199686d,-0.036393538d,-0.00243039d,-0.015870241d,-0.014706978d,-0.00145408d,0.016368784d,-0.011632638d,-0.014623888d,-0.01229736d,-0.01553788d,0.040880412d,0.023929998d,-0.014623888d,0.002648502d,0.031906664d,-0.033734649d,-0.026755067d,0.002783524d,0.005359322d,0.009970833d,0.001412535d,0.016950415d,0.016285693d,-0.006730312d,-0.02459472d,0.050851244d,-0.001827986d,-0.020855658d,0.020938748d,0.004071423d,-0.021603471d,-0.007852031d,-0.023929998d,-0.029912498d,-0.003365156d,0.017365867d,-0.010427829d,-0.011715728d,0.014956249d,0.011383367d,0.032405205d,-0.028583053d,-0.017448956d,0.018446039d,0.017615138d,0.035728816d,-0.010095468d,-0.00254464d,0.010012378d,0.028250692d,-0.020855658d,-0.002305755d,-0.001002276d,-0.014125346d,-0.007021128d,-0.028583053d,-0.045533467d,-0.02758597d,-0.020440206d,0.001350217d,0.010053922d,0.020689478d,-0.017615138d,0.026422706d,0.040880412d,0.012463541d,-0.010718645d,-0.014706978d,0.068134025d,0.038720068d,0.047859997d,-0.012546631d,0.015704062d,-0.002087643d,-0.010303194d,0.014790068d,0.018612221d,0.007395034d,-0.014790068d,-0.017864408d,-0.005068507d,-0.054507218d,0.004902326d,-0.004050651d,0.021603471d,0.019775484d,-0.024262359d,-0.012795902d,0.021935832d,-0.004009106d,-0.039717149d,0.037556801d,-0.016701145d,-0.025757983d,0.005483958d,-0.005110051d,-0.021935832d,-0.003406701d,0.010594009d,0.015787151d,-0.049854163d,0.007727395d,-0.008392117d,-0.017199686d,0.009970833d,-0.008849114d,-0.013876075d,-0.0059825d,-0.015870241d,-0.007104218d,0.028250692d,-0.029081594d,0.026921248d,0.00299125d,-0.017781317d,0.042542219d,0.018196769d,0.052845411d,-0.004819236d,-0.014125346d,0.02459472d,-0.011715728d,0.015787151d,-0.005774774d,0.004902326d,-0.004964644d,-0.02758597d,-0.013959166d,-0.033568468d,-0.027918331d,-0.017698228d,0.003489791d,-0.020024756d,-0.021603471d,0.019360034d,0.028084511d,-0.002503094d,-0.018861491d,-0.002295369d,0.050851244d,-0.020689478d,-0.000459593d,-0.026090344d,0.002783524d,-0.005899409d,-0.026921248d,-0.0093892d,-0.004112968d,0.031574301d,0.003926015d,-0.032903746d,-0.046198189d,-0.019027673d,-0.00913993d,0.030411039d,-0.019443123d,0.001963008d,-0.005193142d,0.010884825d,-0.02127111d,-0.025259443d,0.032737568d,0.00089322d,0.003282066d,0.001713737d,-0.006439496d,0.016867325d,-0.031574301d,0.031075761d,-0.009970833d,0.022600554d,-0.023597637d,-0.014956249d,0.004009106d,0.00198378d,0.026588887d,-0.023431456d,-0.023763817d,-0.013294443d,-0.029746316d,0.001381376d,-0.042874578d,-0.00913993d,0.014873158d,0.016202603d,0.012878992d,-0.006024044d,0.009638472d,0.010552464d,-0.017033506d,-0.027087428d,0.044536386d,-0.038055345d,0.001329444d,-0.019609304d,0.023597637d,-0.043206941d,0.040049512d,0.017615138d,0.046862911d,0.02127111d,0.013294443d,-0.039550968d,-0.018861491d,-0.019609304d,-0.033734649d,0.00623177d,-0.017199686d,0.041212775d,-0.017781317d,-0.024262359d,0.054507218d,-0.009721561d,0.005816319d,-0.00206687d,-0.008766023d,0.017365867d,-0.000737426d,0.018362951d,-0.023597637d,-0.019110762d,0.021935832d,0.041545134d,-0.020357117d,-0.017615138d,0.044868745d,-0.018030589d,-0.032405205d,-0.050186522d,-0.014540797d,0.005213914d,-0.006688767d,0.047527634d,0.040714234d));
    34 String indexName = "vector_index";
    35 FieldSearchPath fieldSearchPath = fieldPath("plot_embedding_voyage_3_large");
    36 int limit = 10;
    37 int numCandidates = 150;
    38
    39 // define pipeline
    40 List<Bson> pipeline = asList(
    41 vectorSearch(
    42 fieldSearchPath,
    43 queryVector,
    44 indexName,
    45 limit,
    46 approximateVectorSearchOptions(numCandidates)),
    47 project(
    48 fields(exclude("_id"), include("title"), include("plot"),
    49 metaVectorSearchScore("score"))));
    50
    51 // run query and print results
    52 collection.aggregate(pipeline)
    53 .forEach(doc -> System.out.println(doc.toJson()));
    54 }
    55 }
    56}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Compile and run the BasicQuery.java file:

javac BasicQuery.java
java BasicQuery
1{"plot": "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title": "About Time", "score": 0.7710106372833252}
2{"plot": "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title": "Retroactive", "score": 0.760047972202301}
3{"plot": "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title": "A.P.E.X.", "score": 0.7576861381530762}
4{"plot": "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title": "Timecop", "score": 0.7576561570167542}
5{"plot": "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title": "Back to the Future Part II", "score": 0.7521393895149231}
6{"plot": "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title": "Thrill Seekers", "score": 0.7509932518005371}
7{"plot": "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title": "Timerider: The Adventure of Lyle Swann", "score": 0.7502642869949341}
8{"plot": "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title": "The Time Machine", "score": 0.7502503395080566}
9{"plot": "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title": "The Time Traveler's Wife", "score": 0.749496340751648}
10{"plot": "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title": "The Final Countdown", "score": 0.7469133734703064}
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlasVectorSearchQuery.kt.

  2. Copy and paste the following sample query into the atlasVectorSearchQuery.kt file:

    1import com.mongodb.client.model.Aggregates
    2import com.mongodb.client.model.Projections
    3import com.mongodb.client.model.search.SearchPath.fieldPath
    4import com.mongodb.client.model.search.VectorSearchOptions
    5import com.mongodb.kotlin.client.coroutine.MongoClient
    6import kotlinx.coroutines.flow.count
    7import org.bson.Document
    8
    9data class Movie(val title: String, val plot: String, val score: Double?)
    10
    11suspend fun main() {
    12
    13 // Replace the placeholder with your Atlas connection string
    14 val uri = "<connection-string>"
    15 val client = MongoClient.create(uri)
    16
    17 try {
    18 // Connect to your cluster
    19 val database = client.getDatabase("sample_mflix")
    20 val collection = database.getCollection<Movie>("embedded_movies")
    21
    22 // Define the pipeline with $vectorSearch query options
    23 val queryVector = listOf(
    24 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234,
    25 )
    26 val path = fieldPath("plot_embedding_voyage_3_large")
    27 val index = "vector_index"
    28 val limit = 10L
    29 val numCandidates = 150L
    30
    31 val pipeline = listOf(
    32 Aggregates.vectorSearch(
    33 path,
    34 queryVector,
    35 index,
    36 limit,
    37 VectorSearchOptions.approximateVectorSearchOptions(numCandidates)
    38 ),
    39 Aggregates.project(
    40 Projections.fields(
    41 Projections.excludeId(),
    42 Projections.include(Movie::plot.name),
    43 Projections.include(Movie::title.name),
    44 Projections.metaVectorSearchScore(Movie::score.name)
    45 )
    46 )
    47 )
    48
    49 // Run the pipeline
    50 val resultsFlow = collection.aggregate<Document>(pipeline)
    51
    52 // Print results
    53 val resultCount = resultsFlow.count()
    54 if (resultCount > 0) {
    55 resultsFlow.collect { result ->
    56 println(result.toJson())
    57 }
    58 } else {
    59 println("No results found.")
    60 }
    61 } catch (e: Exception) {
    62 println("Error occurred: ${e.message}")
    63 } finally {
    64 client.close()
    65 }
    66}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the atlasVectorSearchQuery.kt file in your IDE. The output should resemble the following:

1{"plot": "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title": "About Time", "score": 0.7710106372833252}
2{"plot": "A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.", "title": "Retroactive", "score": 0.760047972202301}
3{"plot": "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title": "A.P.E.X.", "score": 0.7576861381530762}
4{"plot": "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title": "Timecop", "score": 0.7576561570167542}
5{"plot": "After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.", "title": "Back to the Future Part II", "score": 0.7521393895149231}
6{"plot": "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title": "Thrill Seekers", "score": 0.7509932518005371}
7{"plot": "Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...", "title": "Timerider: The Adventure of Lyle Swann", "score": 0.7502642869949341}
8{"plot": "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title": "The Time Machine", "score": 0.7502503395080566}
9{"plot": "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title": "The Time Traveler's Wife", "score": 0.749496340751648}
10{"plot": "A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.", "title": "The Final Countdown", "score": 0.7469133734703064}
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.js .

  2. Copy and paste the following sample query into the atlas-vector-search-quick-start.js file:

    1const { MongoClient } = require("mongodb");
    2
    3// connect to your cluster
    4const uri = "<connection-string>";
    5
    6const client = new MongoClient(uri);
    7
    8async function run() {
    9 try {
    10 await client.connect();
    11
    12 // set namespace
    13 const database = client.db("sample_mflix");
    14 const coll = database.collection("embedded_movies");
    15
    16 // define pipeline
    17 const agg = [
    18 {
    19 '$vectorSearch': {
    20 'index': 'vector_index',
    21 'path': 'plot_embedding_voyage_3_large',
    22 'queryVector': [
    23 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234
    24 ],
    25 'numCandidates': 150,
    26 'limit': 10
    27 }
    28 }, {
    29 '$project': {
    30 '_id': 0,
    31 'plot': 1,
    32 'title': 1,
    33 'score': {
    34 '$meta': 'vectorSearchScore'
    35 }
    36 }
    37 }
    38 ];
    39 // run pipeline
    40 const result = coll.aggregate(agg);
    41
    42 // print results
    43 await result.forEach((doc) => console.dir(JSON.stringify(doc)));
    44 } finally {
    45 await client.close();
    46 }
    47}
    48run().catch(console.dir);

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

node atlas-vector-search-quick-start.js
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.php.

  2. Copy and paste the following sample query into the atlas-vector-search-quick-start.php file:

    atlas-vector-search-quick-start.php
    1<?php
    2
    3require 'vendor/autoload.php';
    4
    5// Replace the placeholder with your Atlas connection string
    6$uri = '<connection-string>';
    7
    8try {
    9
    10 // Connect to your cluster
    11 $client = new MongoDB\Client($uri);
    12
    13 // Set the namespace
    14 $database = $client->selectDatabase('sample_mflix');
    15 $collection = $database->selectCollection('embedded_movies');
    16
    17 // Define the pipeline with $vectorSearch query options
    18 $pipeline = [
    19 [
    20 '$vectorSearch' => [
    21 'queryVector' => [
    22 -0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234
    23 ],
    24 'index' => 'vector_index',
    25 'path' => 'plot_embedding_voyage_3_large',
    26 'numCandidates' => 150,
    27 'limit' => 10
    28 ]
    29 ],
    30 [
    31 '$project' => [
    32 '_id' => 0,
    33 'plot' => 1,
    34 'title' => 1,
    35 'score' => [
    36 '$meta' => 'vectorSearchScore'
    37 ]
    38 ]
    39 ]
    40 ];
    41
    42 // Run the pipeline
    43 $result = $collection->aggregate($pipeline);
    44
    45 // Print results
    46 foreach ($result as $document) {
    47 echo json_encode($document) . "\n";
    48 }
    49
    50} catch (MongoDB\Driver\Exception\Exception $e) {
    51 echo "Error: " . $e->getMessage() . "\n";
    52}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

php atlas-vector-search-quick-start.php
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas-vector-search-quick-start.py.

  2. Copy and paste the following sample query into the atlas-vector-search-quick-start.py file:

    1import pymongo
    2
    3# connect to your cluster
    4client = pymongo.MongoClient("<connection-string>")
    5
    6# define pipeline
    7pipeline = [
    8 {
    9 '$vectorSearch': {
    10 'index': 'vector_index',
    11 'path': 'plot_embedding_voyage_3_large',
    12 'queryVector': [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234],
    13 'numCandidates': 150,
    14 'limit': 10
    15 }
    16 }, {
    17 '$project': {
    18 '_id': 0,
    19 'plot': 1,
    20 'title': 1,
    21 'score': {
    22 '$meta': 'vectorSearchScore'
    23 }
    24 }
    25 }
    26]
    27
    28# run pipeline
    29result = client["sample_mflix"]["embedded_movies"].aggregate(pipeline)
    30
    31# print results
    32for i in result:
    33 print(i)
    34

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

python atlas-vector-search-quick-start.py
1{'plot': 'At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.', 'title': 'About Time', 'score': 0.7710106372833252}
2{'plot': 'A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.', 'title': 'Retroactive', 'score': 0.760047972202301}
3{'plot': 'A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...', 'title': 'A.P.E.X.', 'score': 0.7576861381530762}
4{'plot': 'An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.', 'title': 'Timecop', 'score': 0.7576561570167542}
5{'plot': 'After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.', 'title': 'Back to the Future Part II', 'score': 0.7521393895149231}
6{'plot': 'A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.', 'title': 'Thrill Seekers', 'score': 0.7509932518005371}
7{'plot': 'Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...', 'title': 'Timerider: The Adventure of Lyle Swann', 'score': 0.7502642869949341}
8{'plot': 'Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.', 'title': 'The Time Machine', 'score': 0.7502503395080566}
9{'plot': 'A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.', 'title': "The Time Traveler's Wife", 'score': 0.749496340751648}
10{'plot': 'A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.', 'title': 'The Final Countdown', 'score': 0.7469133734703064}
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. Create a file named atlas_vector_search_quick_start.rb .

  2. Copy and paste the following sample query into the atlas_vector_search_quick_start.rb file:

    1require 'mongo'
    2require 'json'
    3
    4# Replace the placeholder with your Atlas connection string
    5uri = "<connection-string>"
    6
    7begin
    8 # Connect to the MongoDB client
    9 client = Mongo::Client.new(uri, database: 'sample_mflix')
    10
    11 # Set the namespace
    12 db = client.database
    13 collection = db[:embedded_movies]
    14
    15 # Define the pipeline with $vectorSearch query options
    16 pipeline = [
    17 {
    18 '$vectorSearch' => {
    19 'queryVector' => [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234],
    20 'index' => 'vector_index',
    21 'path' => 'plot_embedding_voyage_3_large',
    22 'numCandidates' => 150,
    23 'limit' => 10
    24 }
    25 },
    26 {
    27 '$project' => {
    28 '_id' => 0,
    29 'plot' => 1,
    30 'title' => 1,
    31 'score' => { '$meta' => 'vectorSearchScore' }
    32 }
    33 }
    34 ]
    35
    36 # Run the pipeline
    37 results = collection.aggregate(pipeline)
    38
    39 # Print results
    40 results.each do |document|
    41 puts JSON(document)
    42 end
    43
    44rescue Mongo::Error::NoServerAvailable => e
    45 puts "Failed to connect to MongoDB: #{e.message}"
    46
    47rescue Mongo::Error::OperationFailure => e
    48 puts "Failed to run aggregation: #{e.message}"
    49
    50rescue Mongo::Error => e
    51 puts "A MongoDB error occurred: #{e.message}"
    52
    53rescue StandardError => e
    54 puts "A general error occurred: #{e.message}"
    55
    56ensure
    57 client&.close
    58 puts "MongoDB client closed."
    59end

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Run the following command to query your collection:

bundle exec ruby atlas_vector_search_quick_start.rb
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

For more detailed installation instructions, see the MongoDB Rust Driver documentation.

2

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

  1. In the /src directory of your project, create a file named vector_search_query.rs.

  2. Copy and paste the following sample query into the vector_search_query.rs file:

    vector_search_query.rs
    1use mongodb::{
    2 bson::{Document, doc},
    3 Client
    4};
    5use futures::TryStreamExt;
    6
    7#[tokio::main]
    8pub(crate) async fn basic_query() -> mongodb::error::Result<()> {
    9 // Replace the placeholder with your Atlas connection string
    10 let client = Client::with_uri_str("<connection-string>").await?;
    11
    12 let pipeline = vec! [
    13 doc! {
    14 "$vectorSearch": doc! {
    15 "queryVector": [-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234],
    16 "path": "plot_embedding_voyage_3_large",
    17 "numCandidates": 150,
    18 "index": "vector_index",
    19 "limit": 10
    20 }
    21 },
    22 doc! {
    23 "$project": doc! {
    24 "_id": 0,
    25 "plot": 1,
    26 "title": 1,
    27 "score": doc! { "$meta": "vectorSearchScore"
    28 }
    29 }
    30 }
    31 ];
    32 let coll = client.database("sample_mflix").collection::<Document>("embedded_movies");
    33 let mut results = coll.aggregate(pipeline).await?;
    34 while let Some(result) = results.try_next().await? {
    35 println!("{}", result);
    36 }
    37 Ok(())
    38}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4

Since the query vector is a large inline array, add the #![recursion_limit] attribute at the top of your main.rs file. This crate-level attribute and takes effect only in the crate root, not in the vector_search_query.rs module file.

#![recursion_limit = "2560"]
mod vector_search_query;
fn main() -> mongodb::error::Result<()> {
vector_search_query::basic_query()
}
5
cargo run
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

This query searches for documents that include text in the plot field that is semantically related to the term "time travel".

Create a file named VectorQuery.scala. Copy and paste the following code into the file.

VectorQuery.scala
1import org.mongodb.scala._
2import org.mongodb.scala.model._
3import org.mongodb.scala.model.search.SearchPath.fieldPath
4import org.mongodb.scala.model.search.VectorSearchOptions
5
6class VectorQuery {
7 def performVectorQuery() = {
8 val collection =
9 MongoClient("<connection-string>")
10 .getDatabase("sample_mflix")
11 .getCollection("embedded_movies")
12
13 val options: VectorSearchOptions = VectorSearchOptions.approximateVectorSearchOptions(150)
14
15 collection.aggregate(Seq(
16 Aggregates.vectorSearch(fieldPath("plot_embedding_voyage_3_large"),
17 List(-0.034731735,0.008558298,-0.0153717,-0.029912498,0.011549547,0.010261648,-0.011964999,-0.023265276,0.010303194,-0.006896493,-0.00054528,0.003926015,-0.025757983,0.027419789,0.001199616,-0.036227357,-0.005297005,0.021935832,0.010303194,-0.019193852,0.025093261,-0.040049512,-0.033900831,-0.011466458,-0.01827986,-0.0153717,0.023265276,0.007727395,0.000114249,0.005317777,-0.043871664,-0.02127111,-0.019609304,0.016368784,-0.004756918,0.003552109,0.006522586,-0.005400868,-0.015620971,-0.034565553,-0.018695312,-0.023099095,0.050851244,-0.034731735,0.004819236,0.022268193,-0.095719993,0.05517194,-0.046198189,-0.036393538,0.007187308,-0.02459472,-0.036725901,0.009472291,0.019027673,0.020938748,-0.011051006,0.027087428,0.04586583,-0.022600554,-0.05517194,0.044204023,0.01213118,0.047859997,-0.03938479,0.002928932,0.002056484,0.019443123,-0.028583053,0.013543714,0.022932915,0.011632638,0.004923099,0.000389486,0.020024756,-0.024096178,-0.022766734,0.011217186,-0.003198975,0.007104218,-0.047195274,-0.013377533,0.013294443,0.024096178,-0.056501385,-0.026755067,-0.008433662,-0.001911076,0.007976666,-0.008101301,-0.014042255,0.008641388,-0.02176965,0.010012378,-0.000607598,-0.024927082,0.024927082,-0.018612221,-0.001184036,0.005567048,0.001324251,-0.019526213,-0.023597637,0.060489718,-0.010178559,-0.019609304,0.004112968,-0.011217186,-0.031574301,-0.008766023,0.005483958,-0.061819162,-0.023431456,-0.040714234,0.015039339,0.026422706,0.016202603,0.004653055,0.041046593,-0.018030589,0.040381871,-0.002638116,0.013045172,0.004216831,0.005650138,0.027419789,0.003926015,-0.028749233,0.004798463,-0.030244859,0.063813329,0.007145763,-0.017448956,0.025591804,-0.045201108,0.010718645,0.002804297,0.014291527,0.04586583,-0.015205519,-0.021603471,-0.035230275,0.00760276,0.033236109,0.016534964,-0.043206941,-0.003115885,-0.026256526,0.005940954,0.016534964,0.024262359,-0.001630647,0.028084511,-0.012795902,0.007270399,0.001381376,-0.009763107,-0.006896493,0.008433662,-0.019360034,0.000386889,0.030411039,0.025591804,0.010469374,0.037722982,-0.001147684,-0.005400868,0.052845411,-0.052513052,0.00768585,-0.004299921,0.00922302,0.011881908,0.012962082,-0.068798743,0.003593654,0.020938748,-0.013792985,-0.034565553,-0.007519669,-0.04021569,-0.020689478,0.006273315,0.046862911,0.006107135,0.002638116,-0.013792985,-0.005400868,-0.020274026,0.007644305,-0.010801735,0.026422706,0.043871664,0.003780607,0.010261648,-0.064145692,0.011881908,-0.009056839,0.009347656,-0.02459472,0.026422706,0.033236109,0.041212775,0.019027673,-0.00315743,0.004424557,0.020689478,-0.0153717,-0.015205519,-0.034897912,0.020274026,0.016867325,0.040714234,-0.022766734,-0.010967916,0.026256526,0.007062673,-0.015953332,-0.007727395,0.031574301,-0.002887387,-0.00614868,0.004569965,0.019027673,0.012878992,0.011798819,0.004258377,-0.019193852,-0.021437289,-0.021603471,0.000301202,-0.051183607,-0.004985416,-0.030078677,0.012629721,0.065142773,-0.031740483,-0.021104928,-0.03938479,-0.003365156,-0.016036423,0.036393538,0.009804652,-0.018612221,0.060489718,-0.003697517,0.000547876,0.063480966,0.02758597,0.010053922,-0.003655972,-0.001485239,0.018362951,0.021104928,-0.003905243,0.019443123,-0.002658889,-0.00380138,-0.013626805,0.035894997,0.035396457,-0.005691683,0.002762751,0.012878992,-0.009596926,-0.009970833,-0.015953332,0.022434372,0.00614868,-0.021188019,0.001557943,-0.020190936,0.009763107,0.017448956,0.006730312,0.005567048,0.019692395,-0.00218112,-0.016867325,0.006854947,0.007976666,0.019193852,0.040880412,0.007353489,-0.02127111,-0.031906664,-0.026755067,-0.017947499,0.040381871,0.042209856,0.00913993,-0.0307434,-0.017781317,-0.015039339,0.03057722,0.017532047,0.0187784,-0.060822077,0.002928932,-0.026422706,-0.005899409,0.039717149,0.026588887,-0.000971118,0.004923099,-0.013626805,0.0187784,-0.031408124,-0.000695881,0.050851244,-0.014457707,-0.007311944,-0.001293092,-0.002139574,-0.019276943,0.00290816,0.019360034,-0.017781317,0.002160347,0.016618054,-0.006522586,0.011798819,0.029247776,-0.02775215,0.010344739,-0.018362951,-0.036725901,-0.015870241,0.015704062,-0.012463541,0.02459472,-0.024096178,0.001152877,-0.031408124,0.025425622,0.027087428,0.00922302,0.034565553,0.015704062,-0.020689478,-0.00517237,-0.014706978,-0.001589101,0.026090344,0.014956249,0.011715728,0.004299921,-0.00913993,0.022434372,-0.03705826,0.048524719,-0.030411039,0.008433662,0.017033506,-0.000511525,-0.031408124,0.005940954,-0.012962082,-0.031574301,0.017448956,0.010178559,-0.011383367,-0.020107845,-0.005151597,0.006647222,0.013128263,0.007145763,0.008059756,-0.045201108,-0.004943871,0.015787151,-0.045201108,-0.020772567,-0.020274026,0.028250692,-0.024262359,-0.004424557,0.009804652,0.000472576,-0.005691683,0.001443693,-0.013294443,0.001412535,0.013211353,-0.01213118,-0.002118802,0.017781317,-0.007353489,-0.031075761,-0.004923099,0.011383367,-0.004486875,-0.010178559,0.016618054,0.014457707,0.023763817,-0.02459472,-0.00388447,0.012546631,-0.007519669,0.015704062,-0.014291527,0.009680017,-0.035562634,0.023763817,0.053510133,-0.0555043,-0.003572882,0.022102011,0.021603471,-0.017282777,-0.001474852,-0.043539301,0.007810486,-0.025757983,-0.005400868,0.029912498,-0.00760276,0.014125346,0.030909581,-0.03340229,-0.009680017,0.018030589,0.008849114,0.03057722,0.019775484,0.014125346,0.031906664,-0.03057722,-0.027087428,-0.023597637,-0.022434372,-0.012878992,0.016285693,-0.021603471,-0.029746316,0.029746316,0.020357117,0.006314861,-0.001158071,0.028749233,-0.045201108,0.011383367,0.011134096,-0.021437289,-0.035728816,0.001827986,0.008267482,-0.057498466,0.01213118,-0.01213118,-0.040548053,0.010718645,0.004798463,-0.004881553,-0.019526213,-0.008558298,0.0059825,-0.000262254,-0.017615138,0.005193142,0.019692395,-0.00198378,-0.002845842,0.012546631,0.006107135,-0.008225936,-0.008890659,0.015870241,0.00517237,0.002596571,-0.010427829,-0.019110762,0.024262359,0.012048089,-0.032405205,0.006522586,0.013211353,0.013211353,-0.038221523,-0.007727395,-0.008267482,-0.019276943,0.001474852,0.031408124,-0.035562634,0.017532047,-0.023431456,-0.015454791,-0.011383367,0.016534964,-0.02176965,0.008682934,0.027253609,0.020190936,-0.0247609,-0.007311944,0.009555381,-0.01852913,-0.011632638,0.011549547,0.027419789,-0.034067012,-0.01229736,0.0307434,0.003946788,0.0046946,0.037722982,0.03057722,-0.010427829,0.002284982,0.033236109,0.030078677,-0.013377533,0.007395034,-0.012048089,0.040714234,-0.028749233,-0.000102565,-0.0059825,-0.041046593,0.017698228,-0.006356406,0.003178203,0.009056839,0.023099095,0.00606559,0.011881908,-0.02127111,-0.001126912,-0.027087428,0.011134096,0.001204809,-0.017033506,0.011051006,-0.014374617,0.017864408,0.023431456,-0.002077257,-0.026755067,-0.043871664,0.025757983,-0.006190225,0.001152877,0.011798819,-0.024262359,0.006564131,-0.070128188,-0.004362239,0.012962082,-0.013626805,-0.001402148,-0.012214269,0.011217186,-0.015953332,0.015787151,0.011134096,0.027253609,0.024262359,-0.048192356,0.009970833,0.018944582,-0.00517237,0.021935832,0.02775215,0.003406701,-0.010884825,0.075113602,-0.015953332,0.007727395,0.026755067,-0.006190225,-0.012712811,0.013377533,0.005940954,-0.008309027,0.02459472,0.002316141,-0.022434372,-0.012712811,0.03057722,-0.015787151,0.026755067,-0.001069787,0.03988333,-0.003697517,0.039550968,-0.019027673,-0.0059825,-0.00031029,-0.012546631,-0.003614427,0.007478124,0.005525503,0.032571387,-0.011798819,-0.011466458,-0.00606559,-0.011798819,0.018446039,0.007976666,0.018944582,-0.02176965,0.026588887,-0.006273315,-0.012463541,-0.007395034,0.012048089,-0.029247776,0.015454791,-0.007145763,0.006481041,-0.015620971,-0.00388447,-0.025757983,-0.001651419,-0.032903746,-0.005068507,0.03938479,0.003926015,0.004715373,0.022600554,-0.012546631,0.022932915,0.007810486,0.040714234,0.019941665,0.013543714,0.003406701,0.010884825,-0.03988333,0.042209856,-0.022766734,0.027419789,-0.029580137,0.043206941,0.022932915,0.021104928,-0.056833744,0.005193142,0.036061179,-0.012878992,0.008516753,-0.02758597,-0.030244859,-0.011798819,0.001111332,-0.014125346,-0.014125346,0.019027673,0.029081594,0.018861491,0.013626805,0.06846638,0.023099095,0.041378956,0.001599488,-0.028749233,0.017781317,0.016285693,0.021603471,-0.018113678,0.011300277,-0.032239024,0.022434372,-0.02459472,-0.013626805,0.005483958,0.013460624,-0.031574301,-0.015620971,0.016451873,0.014790068,-0.008849114,0.011134096,0.00461151,0.015122429,0.036227357,0.00206687,0.000877641,0.022102011,-0.028250692,0.022600554,-0.026422706,0.004029878,-0.032072846,0.017116595,0.010884825,0.019609304,0.00614868,0.005733229,0.016119512,0.002866614,-0.014540797,0.012463541,-0.003905243,0.003759835,-0.000485559,-0.022766734,-0.016285693,0.037722982,0.009513836,0.001506011,0.011964999,0.004029878,0.019941665,-0.000965924,0.002129188,0.015205519,0.071125269,0.022932915,0.005940954,-0.00044661,0.010220103,-0.03423319,-0.016285693,-0.016867325,-0.000659529,-0.008018211,-0.011383367,0.000016634,0.004071423,-0.029413955,0.019941665,-0.00913993,-0.024096178,0.010635555,0.010594009,0.001547556,0.036227357,-0.030078677,0.020772567,0.022268193,-0.014125346,0.008766023,-0.012962082,-0.007187308,0.017033506,-0.007187308,-0.015205519,-0.005608593,0.044536386,-0.001235968,0.007852031,0.001599488,0.005857864,-0.005940954,-0.010510919,-0.005567048,0.006730312,0.016285693,-0.010801735,-0.024428539,0.015122429,-0.02176965,0.01528861,-0.007436579,0.00226421,-0.004715373,0.004507647,0.004341467,0.005525503,-0.031075761,-0.005899409,0.037556801,0.014873158,-0.000342747,0.009970833,-0.019443123,0.023597637,-0.012048089,-0.025259443,0.006024044,-0.01827986,0.010012378,0.016784234,0.013211353,-0.005400868,-0.024428539,-0.02176965,-0.035230275,0.009347656,0.028583053,-0.015704062,-0.017781317,0.00226421,0.001199616,-0.003385928,0.008267482,0.002326528,0.022434372,-0.020190936,-0.015787151,0.000789358,0.031241942,0.011300277,0.001506011,-0.023265276,-0.010967916,0.009056839,0.011300277,-0.030244859,0.007478124,0.001111332,-0.035894997,0.0153717,0.002700434,0.021104928,0.010884825,-0.003344383,0.00768585,0.010386284,0.00452842,-0.014706978,0.028084511,0.013377533,0.014873158,0.046862911,-0.015454791,0.021188019,0.013959166,0.012629721,0.025924165,-0.018695312,-0.00922302,-0.0093892,0.007727395,0.036892079,0.007228854,-0.01229736,0.029247776,-0.004943871,-0.027253609,-0.008433662,0.043206941,0.002825069,0.028583053,-0.023431456,0.034897912,-0.041545134,-0.016534964,0.003053567,-0.012712811,0.002741979,-0.007187308,-0.025093261,-0.045201108,-0.004424557,-0.016618054,-0.008890659,0.008018211,-0.05184833,-0.019526213,-0.013377533,-0.010469374,0.030244859,-0.005068507,0.051183607,0.005483958,-0.006024044,0.035064094,-0.011134096,0.014956249,0.002284982,0.001724123,-0.01229736,0.012629721,0.010261648,0.014540797,0.048857078,-0.029580137,-0.024927082,-0.008350573,-0.03988333,0.000939959,0.013543714,0.013626805,-0.021437289,-0.012962082,0.006771857,0.013709894,-0.0059825,0.035396457,-0.006439496,-0.029580137,0.0046946,0.019609304,-0.007270399,0.014291527,-0.015620971,0.00118923,-0.00760276,-0.017199686,0.023265276,0.026588887,-0.030078677,-0.016701145,-0.025757983,0.004964644,0.026588887,0.043206941,0.011051006,-0.009846197,0.028915415,0.031574301,0.023763817,0.009264565,-0.008433662,-0.035064094,-0.000579035,-0.0247609,0.014125346,0.016618054,0.028749233,-0.052513052,-0.016867325,-0.01238045,0.002741979,0.013709894,0.010718645,0.013626805,0.009596926,-0.004403784,-0.02758597,-0.000945152,0.000420645,0.003759835,0.012546631,-0.011881908,0.008392117,0.012795902,0.005483958,-0.009763107,0.006397951,-0.010801735,0.012795902,-0.03938479,0.005733229,0.005733229,-0.000433627,0.015454791,0.002357686,-0.006564131,0.030244859,-0.024428539,0.016036423,0.014291527,-0.004964644,0.029413955,0.040381871,0.012629721,-0.033568468,-0.026422706,-0.037889164,-0.034399372,-0.03423319,0.021935832,0.004133741,-0.014623888,-0.013543714,-0.05517194,0.004736145,0.006314861,0.00006037,0.006356406,0.003323611,-0.010344739,0.007062673,0.005899409,-0.00623177,-0.001973394,-0.0555043,0.011881908,0.001350217,-0.033069927,-0.026921248,0.022268193,0.028583053,-0.021021837,0.010884825,0.019692395,-0.005442413,0.031574301,-0.014956249,0.01238045,-0.006356406,0.006273315,-0.003095113,-0.014540797,-0.02176965,0.005006189,-0.002658889,0.042542219,-0.02176965,0.017199686,-0.016701145,-0.001599488,0.016950415,-0.021188019,0.017864408,0.023763817,-0.000669915,0.025093261,0.021104928,0.008807569,0.037390623,-0.025591804,-0.003178203,-0.001319058,0.020523297,0.005255459,0.019276943,-0.00226421,0.00760276,-0.057166107,-0.006896493,-0.034067012,0.043871664,0.038221523,0.008101301,0.03988333,0.015870241,0.000955538,-0.004299921,-0.002928932,-0.002118802,-0.020523297,-0.001168457,-0.011134096,-0.000685495,0.003323611,0.011549547,0.034565553,0.029247776,-0.029746316,0.005213914,0.019110762,-0.003302838,0.026422706,0.028915415,-0.036227357,0.033236109,0.038387705,-0.035230275,0.004071423,-0.021935832,0.002928932,0.000976311,0.000527104,-0.006854947,-0.003822153,-0.001199616,0.019858574,-0.002762751,0.039052427,-0.008641388,0.032239024,-0.002295369,0.035396457,0.044536386,-0.029413955,0.025093261,-0.03423319,-0.016867325,-0.008849114,0.008433662,-0.004486875,0.017033506,0.006730312,-0.008599843,-0.008225936,-0.024428539,0.006564131,-0.007561215,-0.032072846,-0.019941665,0.035396457,0.019276943,0.010261648,0.005857864,0.032239024,-0.044204023,-0.018944582,0.002409618,0.032903746,0.05517194,-0.03655972,0.007976666,0.030909581,-0.023929998,0.016368784,0.01528861,-0.00768585,0.02176965,0.013626805,-0.02459472,0.04021569,-0.032737568,0.006854947,-0.011383367,0.014873158,-0.02176965,0.00243039,0.0093892,0.0093892,-0.029580137,0.019858574,0.01827986,0.024428539,0.017864408,-0.028250692,-0.001111332,0.056169022,0.007478124,-0.010718645,0.041046593,-0.015704062,0.034731735,0.002523867,-0.032571387,0.004341467,-0.023597637,-0.011881908,-0.035562634,0.006688767,0.007810486,-0.012712811,0.022600554,0.03057722,0.022600554,0.010552464,0.0307434,-0.009638472,0.02176965,-0.018030589,0.024262359,-0.036227357,-0.020772567,0.001641033,-0.022932915,-0.014623888,0.018362951,0.002575798,0.006190225,-0.011051006,0.021021837,0.019110762,0.02127111,-0.028583053,-0.052180689,-0.014291527,-0.010552464,0.036393538,0.042542219,-0.04586583,-0.001869531,0.008350573,-0.008516753,-0.020772567,0.000294711,0.015704062,-0.014457707,-0.020772567,0.008766023,-0.026588887,-0.004736145,-0.028084511,-0.007519669,0.010552464,-0.016534964,0.006190225,0.012962082,-0.016618054,0.012546631,0.02459472,0.022932915,0.020440206,-0.027918331,-0.008059756,0.020689478,-0.014623888,-0.011466458,-0.006896493,-0.020024756,-0.031408124,0.021603471,0.007270399,-0.03057722,0.008350573,-0.021437289,0.00072704,-0.043871664,0.006314861,-0.017199686,0.02176965,0.024262359,-0.020357117,-0.000542683,-0.005213914,0.001963008,-0.00064395,-0.022434372,0.022102011,-0.006688767,-0.028583053,0.002191506,-0.005047734,0.002368073,0.014956249,0.023929998,-0.003302838,-0.032239024,0.022268193,-0.013377533,-0.010801735,0.003676744,0.009015295,-0.039550968,0.010884825,-0.033568468,0.013709894,-0.029413955,-0.006356406,-0.020274026,0.023597637,0.030909581,0.02176965,0.016285693,0.045533467,-0.024096178,-0.030909581,-0.026422706,0.002783524,-0.010594009,0.004362239,-0.070792913,0.009472291,-0.022102011,0.011134096,-0.017448956,-0.011549547,-0.056833744,0.00082571,0.026588887,-0.013709894,0.002575798,0.02176965,-0.000568649,-0.007270399,0.004279149,-0.042874578,-0.026588887,0.016784234,0.036725901,-0.028915415,-0.009513836,0.017448956,0.002035712,-0.007228854,0.011383367,0.011134096,0.028915415,0.0153717,-0.027087428,0.043871664,-0.005089279,0.006314861,0.014291527,-0.003240521,0.025924165,-0.001230775,-0.015454791,-0.012629721,0.031740483,-0.039717149,-0.031075761,0.006605676,-0.008641388,-0.032239024,0.037722982,-0.03705826,-0.024096178,0.001911076,0.018196769,-0.007353489,-0.011300277,-0.029081594,0.004590738,-0.018030589,-0.026588887,0.010261648,0.038221523,0.008392117,-0.01213118,0.018362951,-0.034731735,-0.017781317,-0.011632638,0.005255459,0.000851675,0.014208436,-0.000039922,-0.000228498,0.014790068,0.00913993,0.0004544,-0.011798819,-0.020440206,0.005899409,0.008350573,0.006314861,0.040548053,0.003427474,-0.010801735,0.008599843,0.002586185,-0.041212775,-0.016368784,0.020024756,0.000965924,-0.021021837,-0.008475208,0.0307434,0.00760276,0.003614427,0.003489791,-0.025924165,0.000799744,0.013460624,-0.020440206,0.048857078,0.004320694,-0.048857078,0.015039339,-0.029580137,0.025924165,0.018861491,-0.014706978,0.000576439,-0.031241942,0.0307434,0.0153717,0.014706978,0.028084511,-0.01238045,-0.031241942,0.018196769,-0.034897912,0.008142847,0.010718645,0.00922302,0.047859997,-0.00072704,-0.010427829,0.007104218,0.026256526,0.012214269,-0.013377533,-0.05184833,0.005276232,0.021935832,-0.007021128,0.009804652,0.007893575,0.024096178,-0.002357686,0.033900831,-0.031740483,0.034565553,-0.036892079,-0.015454791,0.030411039,0.010552464,-0.022268193,-0.001391762,-0.008184392,-0.008558298,0.008475208,-0.009929287,0.010427829,0.041378956,-0.009555381,-0.008724478,-0.039052427,0.034731735,-0.014291527,0.023099095,0.029081594,0.007519669,0.010967916,-0.008142847,0.006190225,-0.031075761,0.033734649,-0.001672192,0.047859997,-0.022434372,-0.007395034,0.01213118,0.056169022,0.002762751,-0.029413955,-0.000763392,-0.015787151,0.010801735,0.008142847,0.029912498,-0.0018176,0.033236109,-0.046198189,-0.002492708,-0.006730312,0.008807569,-0.03655972,0.009430746,-0.053842496,-0.060489718,0.046862911,0.002783524,-0.0187784,0.000571246,0.00760276,0.002482322,0.001319058,-0.014291527,0.001464466,-0.011632638,-0.012463541,-0.004902326,0.000841289,0.006688767,0.030244859,0.018944582,0.000532297,-0.015620971,0.007104218,0.005608593,0.002035712,-0.023763817,0.003032795,0.010594009,-0.023597637,-0.042376038,-0.005255459,0.001199616,-0.0247609,-0.007893575,-0.011632638,0.013045172,-0.005691683,-0.007104218,0.027419789,-0.004320694,-0.005525503,-0.026090344,0.031408124,-0.012795902,-0.007062673,0.000939959,0.000030185,0.004175286,0.014291527,0.033236109,-0.038720068,0.074116521,-0.019692395,0.001589101,0.013792985,-0.056169022,-0.028749233,-0.001599488,0.004175286,0.014790068,0.00162026,-0.007519669,-0.041378956,0.016534964,-0.003572882,-0.002575798,-0.019526213,-0.00922302,-0.033900831,-0.042043675,-0.014208436,0.010178559,0.017698228,0.032239024,0.00913993,0.009264565,-0.012463541,-0.005857864,-0.015870241,0.004486875,0.018861491,-0.000176567,-0.029912498,0.016784234,0.012546631,0.051183607,0.023597637,0.032903746,0.0153717,-0.013377533,-0.000016634,-0.061486799,-0.034565553,0.016119512,0.00380138,-0.003863698,0.004362239,-0.017532047,-0.002762751,0.000102565,-0.021437289,0.029247776,-0.010718645,-0.015870241,-0.016285693,0.010220103,-0.000373906,0.012962082,0.010137013,-0.007228854,0.02127111,-0.029247776,0.018113678,0.009181475,0.002233051,0.014374617,-0.00396756,0.010801735,0.007644305,0.020855658,0.014790068,0.032737568,-0.037390623,0.003032795,0.010801735,-0.01553788,-0.014790068,0.019526213,-0.017947499,-0.007893575,-0.011964999,-0.00614868,-0.005857864,-0.032072846,-0.025924165,0.001163264,-0.013294443,-0.01553788,0.016701145,-0.013460624,-0.001111332,0.00760276,0.01553788,-0.033734649,0.048192356,-0.003282066,0.031906664,0.002845842,0.003240521,0.017116595,-0.01827986,0.006896493,-0.00760276,-0.009680017,-0.02459472,-0.020689478,-0.053510133,0.00614868,-0.010552464,-0.032405205,-0.0307434,0.025093261,0.003635199,-0.008101301,-0.00606559,-0.007436579,0.00606559,-0.012962082,0.026921248,0.009098385,0.046530552,-0.011632638,0.032571387,-0.033900831,0.009846197,0.002866614,0.032903746,0.008973749,0.012712811,0.040049512,0.013626805,-0.026256526,-0.031408124,0.036227357,0.011964999,-0.006024044,-0.001848759,0.015704062,-0.021188019,-0.035064094,-0.013377533,-0.009721561,-0.01553788,0.008766023,0.005400868,0.004507647,-0.018362951,-0.026588887,-0.00913993,-0.025591804,0.035894997,0.021935832,-0.031906664,-0.000602404,0.026422706,-0.006397951,0.006647222,0.0093892,0.020606387,0.00913993,0.015620971,-0.024096178,0.00063616,-0.006564131,0.01238045,-0.013709894,0.000563456,-0.009887742,0.016618054,-0.003323611,0.000451803,0.001609874,0.008682934,0.025259443,0.020024756,-0.027253609,0.010884825,0.028250692,-0.054839578,0.033568468,-0.004902326,0.003053567,0.020274026,-0.015704062,-0.00614868,-0.063813329,0.002482322,0.009763107,-0.001609874,-0.012214269,0.020107845,0.001921462,0.018695312,-0.004923099,0.007270399,-0.023763817,0.005234687,0.003406701,0.002565412,0.007104218,0.000841289,0.016202603,0.01827986,-0.031075761,-0.035562634,-0.025259443,-0.007021128,0.000641353,-0.033069927,0.010718645,0.005650138,0.024927082,-0.002658889,0.00380138,0.009929287,-0.004258377,-0.039717149,-0.022434372,0.025425622,0.00198378,0.006356406,0.017615138,-0.032072846,0.046862911,-0.026921248,0.005940954,0.021603471,-0.002253824,0.002825069,-0.030411039,-0.003115885,0.023597637,-0.004320694,-0.007852031,0.018030589,-0.008724478,-0.005733229,0.032903746,0.013876075,0.015454791,-0.023597637,0.005151597,-0.035396457,0.02176965,-0.012463541,0.025591804,0.014540797,-0.027918331,0.004154514,0.008724478,0.016036423,-0.015870241,0.005400868,-0.017365867,-0.044868745,-0.000485559,0.020357117,-0.00760276,-0.023265276,-0.012048089,0.008433662,0.018362951,-0.006979583,0.0307434,0.008392117,0.027087428,-0.019360034,0.016119512,0.02127111,0.010801735,0.00299125,0.002949705,0.012463541,-0.000025966,0.015953332,0.029413955,0.020024756,0.003780607,0.022102011,-0.031740483,0.01553788,0.010386284,0.028749233,-0.010884825,0.008682934,-0.003531337,-0.05517194,-0.019360034,-0.009347656,-0.002025325,0.003261293,-0.025425622,-0.01553788,-0.000251867,0.014291527,0.012546631,0.035728816,-0.007062673,-0.006605676,0.000384293,-0.005047734,-0.032571387,-0.021188019,-0.02127111,-0.016036423,0.008475208,-0.004009106,0.014291527,-0.008101301,0.004424557,-0.038221523,-0.019360034,0.015039339,-0.015454791,-0.029580137,0.035728816,0.004466102,-0.000778971,-0.005068507,-0.017781317,0.00477769,0.001838372,0.030244859,0.01213118,-0.022932915,-0.005359322,0.037390623,0.005899409,0.002046098,0.037889164,0.016701145,0.010303194,0.02127111,-0.009513836,-0.022268193,-0.005650138,-0.00388447,0.016534964,-0.023265276,-0.00054528,0.004819236,0.004715373,-0.001178843,-0.051183607,-0.00614868,-0.010552464,-0.002741979,-0.009181475,0.023597637,0.019193852,0.017199686,-0.036393538,-0.00243039,-0.015870241,-0.014706978,-0.00145408,0.016368784,-0.011632638,-0.014623888,-0.01229736,-0.01553788,0.040880412,0.023929998,-0.014623888,0.002648502,0.031906664,-0.033734649,-0.026755067,0.002783524,0.005359322,0.009970833,0.001412535,0.016950415,0.016285693,-0.006730312,-0.02459472,0.050851244,-0.001827986,-0.020855658,0.020938748,0.004071423,-0.021603471,-0.007852031,-0.023929998,-0.029912498,-0.003365156,0.017365867,-0.010427829,-0.011715728,0.014956249,0.011383367,0.032405205,-0.028583053,-0.017448956,0.018446039,0.017615138,0.035728816,-0.010095468,-0.00254464,0.010012378,0.028250692,-0.020855658,-0.002305755,-0.001002276,-0.014125346,-0.007021128,-0.028583053,-0.045533467,-0.02758597,-0.020440206,0.001350217,0.010053922,0.020689478,-0.017615138,0.026422706,0.040880412,0.012463541,-0.010718645,-0.014706978,0.068134025,0.038720068,0.047859997,-0.012546631,0.015704062,-0.002087643,-0.010303194,0.014790068,0.018612221,0.007395034,-0.014790068,-0.017864408,-0.005068507,-0.054507218,0.004902326,-0.004050651,0.021603471,0.019775484,-0.024262359,-0.012795902,0.021935832,-0.004009106,-0.039717149,0.037556801,-0.016701145,-0.025757983,0.005483958,-0.005110051,-0.021935832,-0.003406701,0.010594009,0.015787151,-0.049854163,0.007727395,-0.008392117,-0.017199686,0.009970833,-0.008849114,-0.013876075,-0.0059825,-0.015870241,-0.007104218,0.028250692,-0.029081594,0.026921248,0.00299125,-0.017781317,0.042542219,0.018196769,0.052845411,-0.004819236,-0.014125346,0.02459472,-0.011715728,0.015787151,-0.005774774,0.004902326,-0.004964644,-0.02758597,-0.013959166,-0.033568468,-0.027918331,-0.017698228,0.003489791,-0.020024756,-0.021603471,0.019360034,0.028084511,-0.002503094,-0.018861491,-0.002295369,0.050851244,-0.020689478,-0.000459593,-0.026090344,0.002783524,-0.005899409,-0.026921248,-0.0093892,-0.004112968,0.031574301,0.003926015,-0.032903746,-0.046198189,-0.019027673,-0.00913993,0.030411039,-0.019443123,0.001963008,-0.005193142,0.010884825,-0.02127111,-0.025259443,0.032737568,0.00089322,0.003282066,0.001713737,-0.006439496,0.016867325,-0.031574301,0.031075761,-0.009970833,0.022600554,-0.023597637,-0.014956249,0.004009106,0.00198378,0.026588887,-0.023431456,-0.023763817,-0.013294443,-0.029746316,0.001381376,-0.042874578,-0.00913993,0.014873158,0.016202603,0.012878992,-0.006024044,0.009638472,0.010552464,-0.017033506,-0.027087428,0.044536386,-0.038055345,0.001329444,-0.019609304,0.023597637,-0.043206941,0.040049512,0.017615138,0.046862911,0.02127111,0.013294443,-0.039550968,-0.018861491,-0.019609304,-0.033734649,0.00623177,-0.017199686,0.041212775,-0.017781317,-0.024262359,0.054507218,-0.009721561,0.005816319,-0.00206687,-0.008766023,0.017365867,-0.000737426,0.018362951,-0.023597637,-0.019110762,0.021935832,0.041545134,-0.020357117,-0.017615138,0.044868745,-0.018030589,-0.032405205,-0.050186522,-0.014540797,0.005213914,-0.006688767,0.047527634,0.040714234),
18 "vector_index",
19 10,
20 options
21 ),
22 Aggregates.project(
23 Projections.fields(
24 Projections.excludeId(),
25 Projections.include("plot"),
26 Projections.include("title"),
27 Projections.meta(
28 "score", "vectorSearchScore"
29 )
30 )
31 )
32 )).foreach { doc => println(doc.toBsonDocument()) }
33 }
34}

This query uses the $vectorSearch stage to:

  • Compare vector embeddings of the search term against vector embeddings of movie plots in the plot_embedding_voyage_3_large field of the sample_mflix.embedded_movies collection.

  • Consider up to the 150 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie plot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

3

Create a class instance and call the function in your project's Main.scala file.

object Main extends App {
private val queryInstance = new VectorQuery
queryInstance.performVectorQuery()
}
4
sbt:quick-start> ~run
1'{"plot":"At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.","title":"About Time","score":0.7710106372833252}'
2'{"plot":"A psychiatrist makes multiple trips through time to save a woman that was murdered by her brutal husband.","title":"Retroactive","score":0.760047972202301}'
3'{"plot":"A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...","title":"A.P.E.X.","score":0.7576861381530762}'
4'{"plot":"An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.","title":"Timecop","score":0.7576561570167542}'
5'{"plot":"After visiting 2015, Marty McFly must repeat his visit to 1955 to prevent disastrous changes to 1985... without interfering with his first trip.","title":"Back to the Future Part II","score":0.7521393895149231}'
6'{"plot":"A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.","title":"Thrill Seekers","score":0.7509932518005371}'
7'{"plot":"Lyle, a motorcycle champion is traveling the Mexican desert, when he find himself in the action radius of a time machine. So he find himself one century back in the past between rapists, ...","title":"Timerider: The Adventure of Lyle Swann","score":0.7502642869949341}'
8'{"plot":"Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.","title":"The Time Machine","score":0.7502503395080566}'
9`{"plot":"A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.","title":"The Time Traveler's Wife","score":0.749496340751648}`
10'{"plot":"A modern aircraft carrier is thrown back in time to 1941 near Hawaii, just hours before the Japanese attack on Pearl Harbor.","title":"The Final Countdown","score":0.7469133734703064}'
1

You can go the MongoDB Search page from the Search & Vector Search option, or the Data Explorer.

2

Click the Query button to the right of the index to query.

3

Click Edit Query to view a default query syntax sample in JSON format.

4

Copy and paste the following query into the Query Editor, and then click the Search button in the Query Editor.

1[
2 {
3 "$vectorSearch": {
4 "index": "autoembed_index",
5 "path": "fullplot",
6 "query": {
7 "text": "journey through the country side"
8 },
9 "numCandidates": 100,
10 "limit": 10
11 }
12 },
13 {
14 "$project": {
15 "_id": 0,
16 "title": 1,
17 "fullplot": 1,
18 "score": { "$meta": "vectorSearchScore" }
19 }
20 }
21]
1SCORE: 0.504997968673706 _id: "573a13d6f29313caabd9f296"
2 awards: Object
3 cast: Array (4)
4 countries: Array (1)
5 fullplot: "The Yorkshire Dales provides the backdrop for the story of a young lad…"
6 title: "Lad: A Yorkshire Story"
7
8SCORE: 0.5045041441917419 _id: "573a13a5f29313caabd14875"
9 awards: Object
10 cast: Array (4)
11 countries: Array (1)
12 fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother …"
13 title: "The Land Beyond the Sunset"
14
15SCORE: 0.5045022964477539 _id: "573a1390f29313caabcd4323"
16 awards: Object
17 cast: Array (4)
18 countries: Array (1)
19 fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother …"
20 title: "The Land Beyond the Sunset"
21
22SCORE: 0.5043178796768188 _id: "573a13bdf29313caabd5950b"
23 awards: Object
24 cast: Array (4)
25 countries: Array (2)
26 fullplot: "A care-giver at a small retirement home takes one of her patients for …"
27 title: "The Mourning Forest"
28
29SCORE: 0.5042794346809387 _id: "573a13c1f29313caabd66109"
30 awards: Object
31 countries: Array (1)
32 directors: Array (1)
33 fullplot: "Set in a small farming community in mid Wales, a place where Koppel's …"
34 title: "Sleep Furiously"
35
36SCORE: 0.5041840672492981 _id: "573a139af29313caabcf0c6b"
37 awards: Object
38 cast: Array (1)
39 countries: Array (1)
40 fullplot: "Robinson is commissioned to investigate the unspecified "problem of En…"
41 title: "Robinson in Space"
42
43SCORE: 0.5041588544845581 _id: "573a13b6f29313caabd47374"
44 awards: Object
45 cast: Array (4)
46 countries: Array (1)
47 fullplot: "A trip to the pastoral countryside reveals a dark, sinister reality fo…"
48 title: "The Banishment"
49
50SCORE: 0.5041133165359497 _id: "573a13a3f29313caabd0f253"
51 awards: Object
52 cast: Array (3)
53 countries: Array (1)
54 fullplot: "A young man takes a journey on a cart through jungles to reach the sma…"
55 title: "The Village Had No Walls"
56
57SCORE: 0.5040709972381592 _id: "573a13aef29313caabd2da6c"
58 awards: Object
59 cast: Array (4)
60 countries: Array (3)
61 fullplot: "The two men embark on parallel, if separate, journeys. Their yearning …"
62 title: "Travelers and Magicians"
63
64SCORE: 0.5040245652198792 _id: "573a13c9f29313caabd7909f"
65 awards: Object
66 countries: Array (3)
67 directors: Array (2)
68 fullplot: "In the summer of 2003, a group of shepherds took a herd of sheep one f…"
69 title: "Sweetgrass"
70

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

1

On the Database screen, click the sample_airbnb database, then click the listingsAndReviews collection.

2

To run this query in MongoDB Compass:

  1. Click the Aggregations tab.

  2. Click </> Text to switch to JSON view.

  3. Copy and paste to run the following query:

    1[
    2 {
    3 "$vectorSearch": {
    4 "index": "autoembed_index",
    5 "path": "fullplot",
    6 "query": {
    7 "text": "journey through the country side"
    8 },
    9 "numCandidates": 100,
    10 "limit": 10
    11 }
    12 },
    13 {
    14 "$project": {
    15 "_id": 0,
    16 "title": 1,
    17 "fullplot": 1,
    18 "score": { "$meta": "vectorSearchScore" }
    19 }
    20 }
    21]
    1title: "Lad: A Yorkshire Story"
    2fullplot: "The Yorkshire Dales provides the backdrop for the story of a young lad…"
    3score: 0.504997968673706
    4
    5title: "The Land Beyond the Sunset"
    6fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother …"
    7score: 0.5045041441917419
    8
    9title: "The Land Beyond the Sunset"
    10fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother …"
    11score: 0.5045022964477539
    12
    13title: "The Mourning Forest"
    14fullplot: "A care-giver at a small retirement home takes one of her patients for …"
    15score: 0.5043178796768188
    16
    17title: "Sleep Furiously"
    18fullplot: "Set in a small farming community in mid Wales, a place where Koppel's …"
    19score: 0.5042794346809387
    20
    21title: "Robinson in Space"
    22fullplot: "Robinson is commissioned to investigate the unspecified "problem of En…"
    23score: 0.5041840672492981
    24
    25title: "The Banishment"
    26fullplot: "A trip to the pastoral countryside reveals a dark, sinister reality fo…"
    27score: 0.5041588544845581
    28
    29title: "The Village Had No Walls"
    30fullplot: "A young man takes a journey on a cart through jungles to reach the sma…"
    31score: 0.5041133165359497
    32
    33title: "Travelers and Magicians"
    34fullplot: "The two men embark on parallel, if separate, journeys. Their yearning …"
    35score: 0.5040709972381592
    36
    37title: "Sweetgrass"
    38fullplot: "In the summer of 2003, a group of shepherds took a herd of sheep one f…"
    39score: 0.5040245652198792
    40

    For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

1

Copy and paste the following sample query into your terminal and then run it using mongosh.

1db.movies.aggregate([
2 {
3 "$vectorSearch": {
4 "index": "autoembed_index",
5 "path": "fullplot",
6 "query": {
7 "text": "journey through the country side"
8 },
9 "numCandidates": 100,
10 "model": "voyage-4",
11 "limit": 10
12 }
13 },
14 {
15 "$project": {
16 "_id": 0,
17 "title": 1,
18 "fullplot": 1,
19 "score": {"$meta": "vectorSearchScore"}
20 }
21 }
22])
1[
2 {
3 title: 'Lad: A Yorkshire Story',
4 fullplot: 'The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.',
5 score: 0.771453320980072
6 },
7 {
8 title: 'Sleep Furiously',
9 fullplot: "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.",
10 score: 0.7415832281112671
11 },
12 {
13 title: 'The Mourning Forest',
14 fullplot: 'A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.',
15 score: 0.7365885376930237
16 },
17 {
18 title: 'The Banishment',
19 fullplot: 'A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.',
20 score: 0.7326775789260864
21 },
22 {
23 title: 'Robinson in Space',
24 fullplot: 'Robinson is commissioned to investigate the unspecified "problem of England." The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.',
25 score: 0.7297798991203308
26 },
27 {
28 title: 'The Village Had No Walls',
29 fullplot: 'A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.',
30 score: 0.7290745973587036
31 },
32 {
33 fullplot: "Seeking escape from his stalled relationship and unhappy place in the world, a recently pink-slipped music teacher sets out to hike Kentucky's Sheltowee Trace Trail. Among the verdant hills of Appalachia, he encounters various strange characters and becomes the reluctant companion of a gregarious father and son who ultimately help him rediscover what he's been missing.",
34 title: 'Pilgrim Song',
35 score: 0.7271398305892944
36 },
37 {
38 title: 'Oyster Farmer',
39 fullplot: "Jack Flange leaves the big city for a respite in Australia's Hawkesbury River region, where generations of oyster fishermen (and maybe one woman) have made a living, built histories, and piled up grievances. Jack finds a small-town mentality, with pluses and minuses. There's also a recent burglary and lots of missing cash. Jack gets a job oystering; his boss is separated from a woman of invention, Jack's attracted to a chambermaid turned letter carrier, and there are plenty of mine fields for a city boy to step through. Jack also has a sister, who's ill, to worry about. It's a river journey of self discovery. Is he passing through, or has he found home?",
40 score: 0.726546049118042
41 },
42 {
43 title: 'Travelers and Magicians',
44 fullplot: "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?",
45 score: 0.7238565683364868
46 },
47 {
48 title: 'The Earthling',
49 fullplot: 'Patrick Foley has been on the move all his life. Tired of drifting, he wants to spend his last days in an isolated Australian valley where he grew up. On his difficult journey he meets Shawn, a little desperate city-boy whose parents were killed in an accident in this remote inhospitable territory. Being unable to accompany the boy back to the civilized world he reluctantly takes him with him on his trip to that valley and teaches him in a rugged way how to survive ...',
50 score: 0.7230214476585388
51 }
52]

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

1

Copy and paste the following code into the Program.cs file in your VectorSearch directory, replacing the existing contents:

Program.cs
1using MongoDB.Bson;
2using MongoDB.Driver;
3
4var connectionString = "<connection string>";
5var client = new MongoClient(connectionString);
6var database = client.GetDatabase("sample_mflix");
7var collection = database.GetCollection<BsonDocument>("movies");
8
9var pipeline = new[]
10{
11 new BsonDocument("$vectorSearch", new BsonDocument
12 {
13 { "index", "autoembed_index" },
14 { "path", "fullplot" },
15 { "query", new BsonDocument("text", "journey through the country side") },
16 { "numCandidates", 100 },
17 { "model", "voyage-4" },
18 { "limit", 10 }
19 }),
20 new BsonDocument("$project", new BsonDocument
21 {
22 { "_id", 0 },
23 { "title", 1 },
24 { "fullplot", 1 },
25 { "score", new BsonDocument("$meta", "vectorSearchScore") }
26 })
27};
28
29var results = collection.Aggregate<BsonDocument>(pipeline).ToList();
30
31foreach (var result in results)
32{
33 Console.WriteLine(result.ToJson());
34}

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

2

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

3
dotnet run
1{ "title" : "Lad: A Yorkshire Story", "fullplot" : "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score" : 0.50499796867370605 }
2{ "title" : "The Land Beyond the Sunset", "fullplot" : "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score" : 0.50450414419174194 }
3{ "title" : "The Land Beyond the Sunset", "fullplot" : "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score" : 0.50450229644775391 }
4{ "title" : "The Mourning Forest", "fullplot" : "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score" : 0.50431787967681885 }
5{ "title" : "Sleep Furiously", "fullplot" : "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score" : 0.50427943468093872 }
6{ "title" : "Robinson in Space", "fullplot" : "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score" : 0.5041840672492981 }
7{ "title" : "The Banishment", "fullplot" : "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score" : 0.50415885448455811 }
8{ "title" : "The Village Had No Walls", "fullplot" : "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score" : 0.50411331653594971 }
9{ "title" : "Travelers and Magicians", "fullplot" : "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score" : 0.50407099723815918 }
10{ "title" : "Sweetgrass", "fullplot" : "In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.", "score" : 0.50402456521987915 }
1

Create a new Go file to connect to your deployment and query the auto-embedding MongoDB Vector Search index that you created in the previous step.

2
main.go
1package main
2
3import (
4 "context"
5 "encoding/json"
6 "fmt"
7 "log"
8 "time"
9
10 "go.mongodb.org/mongo-driver/v2/bson"
11 "go.mongodb.org/mongo-driver/v2/mongo"
12 "go.mongodb.org/mongo-driver/v2/mongo/options"
13)
14
15const (
16 indexName = "autoembed_index"
17)
18
19func main() {
20 // Replace with your MongoDB connection string.
21 uri := "<connection-string>"
22
23 // Create a context with a timeout for querying.
24 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
25 defer cancel()
26
27 // Connect to your deployment.
28 client, err := mongo.Connect(options.Client().ApplyURI(uri))
29 if err != nil {
30 log.Fatalf("Failed to connect to MongoDB: %v", err)
31 }
32 defer func() {
33 if err := client.Disconnect(context.Background()); err != nil {
34 log.Printf("Error disconnecting client: %v", err)
35 }
36 }()
37
38 // Access your database and collection.
39 db := client.Database("sample_mflix")
40 coll := db.Collection("movies")
41
42 // Run a $vectorSearch query using the auto-embedding index.
43 if err := runVectorSearchQuery(ctx, coll); err != nil {
44 log.Fatalf("Failed to run $vectorSearch query: %v", err)
45 }
46}
47
48func runVectorSearchQuery(ctx context.Context, coll *mongo.Collection) error {
49 pipeline := mongo.Pipeline{
50 {{
51 "$vectorSearch", bson.D{
52 {"index", indexName},
53 {"path", "fullplot"},
54 {"query", bson.D{
55 {"text", "journey through the country side"},
56 }},
57 {"numCandidates", 100},
58 {"limit", 10},
59 },
60 }},
61 {{
62 "$project", bson.D{
63 {"_id", 0},
64 {"title", 1},
65 {"fullplot", 1},
66 {"score", bson.D{{"$meta", "vectorSearchScore"}}},
67 },
68 }},
69 }
70
71 cursor, err := coll.Aggregate(ctx, pipeline)
72 if err != nil {
73 return fmt.Errorf("aggregate: %w", err)
74 }
75 defer cursor.Close(ctx)
76
77 fmt.Println("Query results:")
78 for cursor.Next(ctx) {
79 var doc bson.M
80 if err := cursor.Decode(&doc); err != nil {
81 return fmt.Errorf("decode result: %w", err)
82 }
83
84 // Marshal each document to compact JSON (Extended JSON for Decimal128, etc.).
85 data, err := json.Marshal(doc)
86 if err != nil {
87 return fmt.Errorf("marshal result to JSON: %w", err)
88 }
89
90 fmt.Println(string(data))
91 }
92 return cursor.Err()
93}

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4

Run the following command to query your collection:

go run main.go
Query results:
{"fullplot":"The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.","score":0.504997968673706,"title":"Lad: A Yorkshire Story"}
{"fullplot":"Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.","score":0.5045041441917419,"title":"The Land Beyond the Sunset"}
{"fullplot":"Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.","score":0.5045022964477539,"title":"The Land Beyond the Sunset"}
{"fullplot":"A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.","score":0.5043178796768188,"title":"The Mourning Forest"}
{"fullplot":"Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.","score":0.5042794346809387,"title":"Sleep Furiously"}
{"fullplot":"Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.","score":0.5041840672492981,"title":"Robinson in Space"}
{"fullplot":"A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.","score":0.5041588544845581,"title":"The Banishment"}
{"fullplot":"A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.","score":0.5041133165359497,"title":"The Village Had No Walls"}
{"fullplot":"The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?","score":0.5040709972381592,"title":"Travelers and Magicians"}
{"fullplot":"In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.","score":0.5040245652198792,"title":"Sweetgrass"}
1
2
runQuery.java
1import static com.mongodb.client.model.Aggregates.*;
2import static com.mongodb.client.model.Projections.*;
3import static com.mongodb.client.model.search.SearchPath.fieldPath;
4import static com.mongodb.client.model.search.VectorSearchOptions.approximateVectorSearchOptions;
5import static com.mongodb.client.model.search.VectorSearchQuery.textQuery;
6import static java.util.Arrays.asList;
7
8import com.mongodb.client.MongoClient;
9import com.mongodb.client.MongoClients;
10import com.mongodb.client.MongoCollection;
11import com.mongodb.client.MongoDatabase;
12import org.bson.Document;
13import org.bson.conversions.Bson;
14
15import java.util.ArrayList;
16import java.util.List;
17
18public class Query {
19 public static void main(String[] args) {
20 // Replace the placeholder with your connection string
21 String uri = "<connectionString>";
22
23 try (MongoClient client = MongoClients.create(uri)) {
24 MongoDatabase database = client.getDatabase("sample_mflix");
25 MongoCollection<Document> collection = database.getCollection("movies");
26
27 List<Bson> pipeline = asList(
28 vectorSearch(
29 fieldPath("fullplot"),
30 textQuery("journey through the country side"),
31 "autoembed_index",
32 10L,
33 approximateVectorSearchOptions(100L)
34 ),
35 project(
36 fields(
37 excludeId(),
38 include("title", "fullplot"),
39 computed("score", new Document("$meta", "vectorSearchScore"))
40 )
41 )
42 );
43
44 List<Document> results = collection.aggregate(pipeline).into(new ArrayList<>());
45 for (Document doc : results) {
46 System.out.println(doc.toJson());
47 }
48 }
49 }
50}

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4
javac runQuery.java
java runQuery
1{"title": "Lad: A Yorkshire Story", "fullplot": "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score": 0.504997968673706}
2{"title": "The Land Beyond the Sunset", "fullplot": "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score": 0.5045041441917419}
3{"title": "The Land Beyond the Sunset", "fullplot": "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score": 0.5045022964477539}
4{"title": "The Mourning Forest", "fullplot": "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score": 0.5043178796768188}
5{"title": "Sleep Furiously", "fullplot": "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score": 0.5042794346809387}
6{"title": "Robinson in Space", "fullplot": "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score": 0.5041840672492981}
7{"title": "The Banishment", "fullplot": "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score": 0.5041588544845581}
8{"title": "The Village Had No Walls", "fullplot": "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score": 0.5041133165359497}
9{"title": "Travelers and Magicians", "fullplot": "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score": 0.5040709972381592}
10{"title": "Sweetgrass", "fullplot": "In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.", "score": 0.5040245652198792}
1
2
run-query.js
1const { MongoClient } = require("mongodb");
2
3async function main() {
4 // Replace the placeholder with your connection string
5 const uri = "<connection-string>";
6 const client = new MongoClient(uri);
7
8 try {
9 await client.connect();
10 const database = client.db("sample_mflix");
11 const collection = database.collection("movies");
12
13 const pipeline = [
14 {
15 "$vectorSearch": {
16 "index": "autoembed_index",
17 "path": "fullplot",
18 "query": {
19 "text": "journey through the country side"
20 },
21 "numCandidates": 100,
22 "limit": 10
23 }
24 },
25 {
26 "$project": {
27 "_id": 0,
28 "title": 1,
29 "fullplot": 1,
30 "score": { "$meta": "vectorSearchScore" }
31 }
32 }
33 ];
34
35 const cursor = collection.aggregate(pipeline);
36 await cursor.forEach(doc => console.log(doc));
37 } finally {
38 await client.close();
39 }
40}
41
42main().catch(console.error);

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4
node run-query.js
1{
2 title: 'Lad: A Yorkshire Story',
3 fullplot: 'The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.',
4 score: 0.504997968673706
5}
6{
7 title: 'The Land Beyond the Sunset',
8 fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.",
9 score: 0.5045041441917419
10}
11{
12 title: 'The Land Beyond the Sunset',
13 fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.",
14 score: 0.5045022964477539
15}
16{
17 title: 'The Mourning Forest',
18 fullplot: 'A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.',
19 score: 0.5043178796768188
20}
21{
22 title: 'Sleep Furiously',
23 fullplot: "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.",
24 score: 0.5042794346809387
25}
26{
27 title: 'Robinson in Space',
28 fullplot: 'Robinson is commissioned to investigate the unspecified "problem of England." The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.',
29 score: 0.5041840672492981
30}
31{
32 title: 'The Banishment',
33 fullplot: 'A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.',
34 score: 0.5041588544845581
35}
36{
37 title: 'The Village Had No Walls',
38 fullplot: 'A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.',
39 score: 0.5041133165359497
40}
41{
42 title: 'Travelers and Magicians',
43 fullplot: "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?",
44 score: 0.5040709972381592
45}
46{
47 title: 'Sweetgrass',
48 fullplot: 'In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.',
49 score: 0.5040245652198792
50}
1
2
run-query.py
1import pymongo
2
3client = pymongo.MongoClient("<connection-string>")
4collection = client["sample_mflix"]["movies"]
5
6result = collection.aggregate([
7 {
8 "$vectorSearch": {
9 "index": "autoembed_index",
10 "path": "fullplot",
11 "query": {
12 "text": "journey through the country side"
13 },
14 "numCandidates": 100,
15 "limit": 10
16 }
17 },
18 {
19 "$project": {
20 "_id": 0,
21 "title": 1,
22 "fullplot": 1,
23 "score": { "$meta": "vectorSearchScore" }
24 }
25 }
26])
27
28for i in result:
29 print(i)

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4
python run-query.py
1{'title': 'Lad: A Yorkshire Story', 'fullplot': 'The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.', 'score': 0.504997968673706}
2{'title': 'The Land Beyond the Sunset', 'fullplot': "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", 'score': 0.5045041441917419}
3{'title': 'The Land Beyond the Sunset', 'fullplot': "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", 'score': 0.5045022964477539}
4{'title': 'The Mourning Forest', 'fullplot': 'A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.', 'score': 0.5043178796768188}
5{'title': 'Sleep Furiously', 'fullplot': "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", 'score': 0.5042794346809387}
6{'title': 'Robinson in Space', 'fullplot': 'Robinson is commissioned to investigate the unspecified "problem of England." The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.', 'score': 0.5041840672492981}
7{'title': 'The Banishment', 'fullplot': 'A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.', 'score': 0.5041588544845581}
8{'title': 'The Village Had No Walls', 'fullplot': 'A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.', 'score': 0.5041133165359497}
9{'title': 'Travelers and Magicians', 'fullplot': "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", 'score': 0.5040709972381592}
10{'title': 'Sweetgrass', 'fullplot': 'In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.', 'score': 0.5040245652198792}
1
  1. Create a file named atlas_vector_search_quick_start.cpp.

  2. Copy and paste the following sample query into the atlas_vector_search_quick_start.cpp file:

    atlas_vector_search_quick_start.cpp
    1#include <bsoncxx/builder/basic/document.hpp>
    2#include <bsoncxx/json.hpp>
    3#include <iostream>
    4#include <mongocxx/client.hpp>
    5#include <mongocxx/instance.hpp>
    6#include <mongocxx/pipeline.hpp>
    7#include <mongocxx/uri.hpp>
    8
    9using bsoncxx::builder::basic::kvp;
    10using bsoncxx::builder::basic::make_document;
    11
    12int main() {
    13 try {
    14 mongocxx::instance inst{};
    15
    16 // Replace the placeholder with your connection string
    17 const auto uri = mongocxx::uri{"<connection-string>"};
    18
    19 // Connect to your cluster
    20 auto client = mongocxx::client{uri};
    21 auto db = client["sample_mflix"];
    22 auto collection = db["movies"];
    23
    24 // Define the pipeline with vectorSearch query options
    25 mongocxx::pipeline stages;
    26
    27 stages
    28 .append_stage(make_document(kvp(
    29 "$vectorSearch",
    30 make_document(
    31 kvp("index", "autoembed_index"), kvp("path", "fullplot"),
    32 kvp("query", make_document(kvp(
    33 "text", "journey through the country side"))),
    34 kvp("numCandidates", 100), kvp("model", "voyage-4"),
    35 kvp("limit", 10)))))
    36 .project(make_document(
    37 kvp("_id", 0), kvp("title", 1), kvp("fullplot", 1),
    38 kvp("score", make_document(kvp("$meta", "vectorSearchScore")))));
    39
    40 auto cursor = collection.aggregate(stages);
    41
    42 for (auto&& doc : cursor) {
    43 std::cout << bsoncxx::to_json(doc) << std::endl;
    44 }
    45 } catch (const std::exception& e) {
    46 std::cout << "Exception: " << e.what() << std::endl;
    47 }
    48 return 0;
    49}

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

3
  1. Replace the vector_index.cpp file name in your CMakeLists.txt file with your new atlas_vector_search_quick_start.cpp filename.

  2. Prepare the project.

    cmake -B build
  3. Build the app.

    cmake --build build
  4. Execute the app to run the query.

    ./query_quick_start
    1{ "title" : "Lad: A Yorkshire Story", "fullplot" : "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score" : 0.50499069690704345703 }
    2{ "title" : "The Mourning Forest", "fullplot" : "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score" : 0.50432574748992919922 }
    3{ "title" : "Sleep Furiously", "fullplot" : "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score" : 0.50427448749542236328 }
    4{ "title" : "Robinson in Space", "fullplot" : "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score" : 0.5041942596435546875 }
    5{ "title" : "The Banishment", "fullplot" : "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score" : 0.50416898727416992188 }
    6{ "title" : "The Village Had No Walls", "fullplot" : "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score" : 0.50411427021026611328 }
    7{ "title" : "Travelers and Magicians", "fullplot" : "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score" : 0.5040524601936340332 }
    8{ "fullplot" : "Seeking escape from his stalled relationship and unhappy place in the world, a recently pink-slipped music teacher sets out to hike Kentucky's Sheltowee Trace Trail. Among the verdant hills of Appalachia, he encounters various strange characters and becomes the reluctant companion of a gregarious father and son who ultimately help him rediscover what he's been missing.", "title" : "Pilgrim Song", "score" : 0.50402408838272094727 }
    9{ "title" : "The Earthling", "fullplot" : "Patrick Foley has been on the move all his life. Tired of drifting, he wants to spend his last days in an isolated Australian valley where he grew up. On his difficult journey he meets Shawn, a little desperate city-boy whose parents were killed in an accident in this remote inhospitable territory. Being unable to accompany the boy back to the civilized world he reluctantly takes him with him on his trip to that valley and teaches him in a rugged way how to survive ...", "score" : 0.50400221347808837891 }
    10{ "title" : "The Garden", "fullplot" : "Jakub's life arrived at a dead-end. He leaves his job, and gets into conflict with his father. The trouble just grows by his relation with a married woman. Breaking out, Jakub realizes the pleasures of the countryside in the old garden of his grandfather. He finds true love with an angel, and encounters various exciting moments of his new free life. Strange visitors arrive, and he wont get back to town anymore.", "score" : 0.50392138957977294922 }

Note

Vector Search Index supports both asynchronous and synchronous runtimes. In the following steps, select your preferred runtime to learn how to create a Vector Search Index for it.

1

Select the tab for the runtime that you use and run the following commands to add the required dependencies:

cargo add mongodb
cargo add tokio --features full
cargo add futures

For further information about Rust with MongoDB, see the MongoDB Rust Driver documentation.

2

In the /src directory of your project, create a file named vector_query.rs, then copy and paste the following sample query into the file.

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

vector_query.rs
1use mongodb::{
2 bson::{Document, doc},
3 Client
4};
5use futures::TryStreamExt;
6
7#[tokio::main]
8pub(crate) async fn auto_embed_query() -> mongodb::error::Result<()> {
9 // Replace the placeholder with your Atlas connection string
10 let client = Client::with_uri_str("<connection-string>").await?;
11
12 let pipeline = vec! [
13 doc! {
14 "$vectorSearch": doc! {
15 "index": "autoembed_index",
16 "path": "fullplot",
17 "query": doc! {
18 "text": "journey through the country side"
19 },
20 "numCandidates": 100,
21 "model": "voyage-4",
22 "limit": 10
23 }
24 },
25 doc! {
26 "$project": doc! {
27 "_id": 0,
28 "title": 1,
29 "fullplot": 1,
30 "score": doc! { "$meta": "vectorSearchScore"
31 }
32 }
33 }
34 ];
35 let coll = client.database("sample_mflix").collection::<Document>("movies");
36 let mut results = coll.aggregate(pipeline).await?;
37 while let Some(result) = results.try_next().await? {
38 println!("{}", result);
39 }
40 Ok(())
41}
3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
mod vector_query;
fn main() -> mongodb::error::Result<()> {
vector_query::auto_embed_query()
}
5
cargo run
1{ "title": "Lad: A Yorkshire Story", "fullplot": "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score": 0.5049906969070435 }
2{ "title": "The Mourning Forest", "fullplot": "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score": 0.5043257474899292 }
3{ "title": "Sleep Furiously", "fullplot": "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score": 0.5042744874954224 }
4{ "title": "Robinson in Space", "fullplot": "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score": 0.5041942596435547 }
5{ "title": "The Banishment", "fullplot": "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score": 0.5041689872741699 }
6{ "title": "The Village Had No Walls", "fullplot": "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score": 0.5041142702102661 }
7{ "title": "Travelers and Magicians", "fullplot": "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score": 0.504052460193634 }
8{ "fullplot": "Seeking escape from his stalled relationship and unhappy place in the world, a recently pink-slipped music teacher sets out to hike Kentucky's Sheltowee Trace Trail. Among the verdant hills of Appalachia, he encounters various strange characters and becomes the reluctant companion of a gregarious father and son who ultimately help him rediscover what he's been missing.", "title": "Pilgrim Song", "score": 0.504024088382721 }
9{ "title": "The Earthling", "fullplot": "Patrick Foley has been on the move all his life. Tired of drifting, he wants to spend his last days in an isolated Australian valley where he grew up.On his difficult journey he meets Shawn, a little desperate city-boy whose parents were killed in an accident in this remote inhospitable territory. Being unable to accompany the boy back to the civilized world he reluctantly takes him with him on his trip to that valley and teaches him in a rugged way how to survive ...", "score": 0.503984808921814 }
10{ "title": "Oyster Farmer", "fullplot": "Jack Flange leaves the big city for a respite in Australia's Hawkesbury River region, where generations of oyster fishermen (and maybe one woman) havemade a living, built histories, and piled up grievances. Jack finds a small-town mentality, with pluses and minuses. There's also a recent burglary and lots of missing cash. Jack gets a job oystering; his boss is separated from a woman of invention, Jack's attracted to a chambermaid turned letter carrier, and there are plenty of mine fields for a city boy to step through. Jack also has a sister, who's ill, to worry about. It's a river journey of self discovery. Is he passing through, or has he found home?", "score": 0.50397789478302 }
1

Copy and paste the following sample query into your terminal and then run it using mongosh.

1db.movies.aggregate([
2 {
3 "$vectorSearch": {
4 "index": "autoembed_index",
5 "path": "fullplot",
6 "query": {
7 "text": "journey through the country side"
8 },
9 "numCandidates": 100,
10 "model": "voyage-4",
11 "limit": 10
12 }
13 },
14 {
15 "$project": {
16 "_id": 0,
17 "title": 1,
18 "fullplot": 1,
19 "score": {"$meta": "vectorSearchScore"}
20 }
21 }
22])
1[
2 {
3 title: 'Lad: A Yorkshire Story',
4 fullplot: 'The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.',
5 score: 0.771453320980072
6 },
7 {
8 title: 'Sleep Furiously',
9 fullplot: "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.",
10 score: 0.7415832281112671
11 },
12 {
13 title: 'The Mourning Forest',
14 fullplot: 'A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.',
15 score: 0.7365885376930237
16 },
17 {
18 title: 'The Banishment',
19 fullplot: 'A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.',
20 score: 0.7326775789260864
21 },
22 {
23 title: 'Robinson in Space',
24 fullplot: 'Robinson is commissioned to investigate the unspecified "problem of England." The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.',
25 score: 0.7297798991203308
26 },
27 {
28 title: 'The Village Had No Walls',
29 fullplot: 'A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.',
30 score: 0.7290745973587036
31 },
32 {
33 fullplot: "Seeking escape from his stalled relationship and unhappy place in the world, a recently pink-slipped music teacher sets out to hike Kentucky's Sheltowee Trace Trail. Among the verdant hills of Appalachia, he encounters various strange characters and becomes the reluctant companion of a gregarious father and son who ultimately help him rediscover what he's been missing.",
34 title: 'Pilgrim Song',
35 score: 0.7271398305892944
36 },
37 {
38 title: 'Oyster Farmer',
39 fullplot: "Jack Flange leaves the big city for a respite in Australia's Hawkesbury River region, where generations of oyster fishermen (and maybe one woman) have made a living, built histories, and piled up grievances. Jack finds a small-town mentality, with pluses and minuses. There's also a recent burglary and lots of missing cash. Jack gets a job oystering; his boss is separated from a woman of invention, Jack's attracted to a chambermaid turned letter carrier, and there are plenty of mine fields for a city boy to step through. Jack also has a sister, who's ill, to worry about. It's a river journey of self discovery. Is he passing through, or has he found home?",
40 score: 0.726546049118042
41 },
42 {
43 title: 'Travelers and Magicians',
44 fullplot: "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?",
45 score: 0.7238565683364868
46 },
47 {
48 title: 'The Earthling',
49 fullplot: 'Patrick Foley has been on the move all his life. Tired of drifting, he wants to spend his last days in an isolated Australian valley where he grew up. On his difficult journey he meets Shawn, a little desperate city-boy whose parents were killed in an accident in this remote inhospitable territory. Being unable to accompany the boy back to the civilized world he reluctantly takes him with him on his trip to that valley and teaches him in a rugged way how to survive ...',
50 score: 0.7230214476585388
51 }
52]

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

1

Copy and paste the following code into the Program.cs file in your VectorSearch directory, replacing the existing contents:

Program.cs
1using MongoDB.Bson;
2using MongoDB.Driver;
3
4var connectionString = "<connection string>";
5var client = new MongoClient(connectionString);
6var database = client.GetDatabase("sample_mflix");
7var collection = database.GetCollection<BsonDocument>("movies");
8
9var pipeline = new[]
10{
11 new BsonDocument("$vectorSearch", new BsonDocument
12 {
13 { "index", "autoembed_index" },
14 { "path", "fullplot" },
15 { "query", new BsonDocument("text", "journey through the country side") },
16 { "numCandidates", 100 },
17 { "model", "voyage-4" },
18 { "limit", 10 }
19 }),
20 new BsonDocument("$project", new BsonDocument
21 {
22 { "_id", 0 },
23 { "title", 1 },
24 { "fullplot", 1 },
25 { "score", new BsonDocument("$meta", "vectorSearchScore") }
26 })
27};
28
29var results = collection.Aggregate<BsonDocument>(pipeline).ToList();
30
31foreach (var result in results)
32{
33 Console.WriteLine(result.ToJson());
34}

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

2

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

3
dotnet run
1{ "title" : "Lad: A Yorkshire Story", "fullplot" : "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score" : 0.50499796867370605 }
2{ "title" : "The Land Beyond the Sunset", "fullplot" : "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score" : 0.50450414419174194 }
3{ "title" : "The Land Beyond the Sunset", "fullplot" : "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score" : 0.50450229644775391 }
4{ "title" : "The Mourning Forest", "fullplot" : "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score" : 0.50431787967681885 }
5{ "title" : "Sleep Furiously", "fullplot" : "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score" : 0.50427943468093872 }
6{ "title" : "Robinson in Space", "fullplot" : "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score" : 0.5041840672492981 }
7{ "title" : "The Banishment", "fullplot" : "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score" : 0.50415885448455811 }
8{ "title" : "The Village Had No Walls", "fullplot" : "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score" : 0.50411331653594971 }
9{ "title" : "Travelers and Magicians", "fullplot" : "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score" : 0.50407099723815918 }
10{ "title" : "Sweetgrass", "fullplot" : "In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.", "score" : 0.50402456521987915 }
1

Create a new Go file to connect to your deployment and query the auto-embedding MongoDB Vector Search index that you created in the previous step.

2
main.go
1package main
2
3import (
4 "context"
5 "encoding/json"
6 "fmt"
7 "log"
8 "time"
9
10 "go.mongodb.org/mongo-driver/v2/bson"
11 "go.mongodb.org/mongo-driver/v2/mongo"
12 "go.mongodb.org/mongo-driver/v2/mongo/options"
13)
14
15const (
16 indexName = "autoembed_index"
17)
18
19func main() {
20 // Replace with your MongoDB connection string.
21 uri := "<connection-string>"
22
23 // Create a context with a timeout for querying.
24 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
25 defer cancel()
26
27 // Connect to your deployment.
28 client, err := mongo.Connect(options.Client().ApplyURI(uri))
29 if err != nil {
30 log.Fatalf("Failed to connect to MongoDB: %v", err)
31 }
32 defer func() {
33 if err := client.Disconnect(context.Background()); err != nil {
34 log.Printf("Error disconnecting client: %v", err)
35 }
36 }()
37
38 // Access your database and collection.
39 db := client.Database("sample_mflix")
40 coll := db.Collection("movies")
41
42 // Run a $vectorSearch query using the auto-embedding index.
43 if err := runVectorSearchQuery(ctx, coll); err != nil {
44 log.Fatalf("Failed to run $vectorSearch query: %v", err)
45 }
46}
47
48func runVectorSearchQuery(ctx context.Context, coll *mongo.Collection) error {
49 pipeline := mongo.Pipeline{
50 {{
51 "$vectorSearch", bson.D{
52 {"index", indexName},
53 {"path", "fullplot"},
54 {"query", bson.D{
55 {"text", "journey through the country side"},
56 }},
57 {"numCandidates", 100},
58 {"limit", 10},
59 },
60 }},
61 {{
62 "$project", bson.D{
63 {"_id", 0},
64 {"title", 1},
65 {"fullplot", 1},
66 {"score", bson.D{{"$meta", "vectorSearchScore"}}},
67 },
68 }},
69 }
70
71 cursor, err := coll.Aggregate(ctx, pipeline)
72 if err != nil {
73 return fmt.Errorf("aggregate: %w", err)
74 }
75 defer cursor.Close(ctx)
76
77 fmt.Println("Query results:")
78 for cursor.Next(ctx) {
79 var doc bson.M
80 if err := cursor.Decode(&doc); err != nil {
81 return fmt.Errorf("decode result: %w", err)
82 }
83
84 // Marshal each document to compact JSON (Extended JSON for Decimal128, etc.).
85 data, err := json.Marshal(doc)
86 if err != nil {
87 return fmt.Errorf("marshal result to JSON: %w", err)
88 }
89
90 fmt.Println(string(data))
91 }
92 return cursor.Err()
93}

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4

Run the following command to query your collection:

go run main.go
Query results:
{"fullplot":"The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.","score":0.504997968673706,"title":"Lad: A Yorkshire Story"}
{"fullplot":"Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.","score":0.5045041441917419,"title":"The Land Beyond the Sunset"}
{"fullplot":"Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.","score":0.5045022964477539,"title":"The Land Beyond the Sunset"}
{"fullplot":"A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.","score":0.5043178796768188,"title":"The Mourning Forest"}
{"fullplot":"Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.","score":0.5042794346809387,"title":"Sleep Furiously"}
{"fullplot":"Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.","score":0.5041840672492981,"title":"Robinson in Space"}
{"fullplot":"A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.","score":0.5041588544845581,"title":"The Banishment"}
{"fullplot":"A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.","score":0.5041133165359497,"title":"The Village Had No Walls"}
{"fullplot":"The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?","score":0.5040709972381592,"title":"Travelers and Magicians"}
{"fullplot":"In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.","score":0.5040245652198792,"title":"Sweetgrass"}
1
2
runQuery.java
1import static com.mongodb.client.model.Aggregates.*;
2import static com.mongodb.client.model.Projections.*;
3import static com.mongodb.client.model.search.SearchPath.fieldPath;
4import static com.mongodb.client.model.search.VectorSearchOptions.approximateVectorSearchOptions;
5import static com.mongodb.client.model.search.VectorSearchQuery.textQuery;
6import static java.util.Arrays.asList;
7
8import com.mongodb.client.MongoClient;
9import com.mongodb.client.MongoClients;
10import com.mongodb.client.MongoCollection;
11import com.mongodb.client.MongoDatabase;
12import org.bson.Document;
13import org.bson.conversions.Bson;
14
15import java.util.ArrayList;
16import java.util.List;
17
18public class Query {
19 public static void main(String[] args) {
20 // Replace the placeholder with your connection string
21 String uri = "<connectionString>";
22
23 try (MongoClient client = MongoClients.create(uri)) {
24 MongoDatabase database = client.getDatabase("sample_mflix");
25 MongoCollection<Document> collection = database.getCollection("movies");
26
27 List<Bson> pipeline = asList(
28 vectorSearch(
29 fieldPath("fullplot"),
30 textQuery("journey through the country side"),
31 "autoembed_index",
32 10L,
33 approximateVectorSearchOptions(100L)
34 ),
35 project(
36 fields(
37 excludeId(),
38 include("title", "fullplot"),
39 computed("score", new Document("$meta", "vectorSearchScore"))
40 )
41 )
42 );
43
44 List<Document> results = collection.aggregate(pipeline).into(new ArrayList<>());
45 for (Document doc : results) {
46 System.out.println(doc.toJson());
47 }
48 }
49 }
50}

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4
javac runQuery.java
java runQuery
1{"title": "Lad: A Yorkshire Story", "fullplot": "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score": 0.504997968673706}
2{"title": "The Land Beyond the Sunset", "fullplot": "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score": 0.5045041441917419}
3{"title": "The Land Beyond the Sunset", "fullplot": "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score": 0.5045022964477539}
4{"title": "The Mourning Forest", "fullplot": "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score": 0.5043178796768188}
5{"title": "Sleep Furiously", "fullplot": "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score": 0.5042794346809387}
6{"title": "Robinson in Space", "fullplot": "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score": 0.5041840672492981}
7{"title": "The Banishment", "fullplot": "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score": 0.5041588544845581}
8{"title": "The Village Had No Walls", "fullplot": "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score": 0.5041133165359497}
9{"title": "Travelers and Magicians", "fullplot": "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score": 0.5040709972381592}
10{"title": "Sweetgrass", "fullplot": "In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.", "score": 0.5040245652198792}
1
2
run-query.js
1const { MongoClient } = require("mongodb");
2
3async function main() {
4 // Replace the placeholder with your connection string
5 const uri = "<connection-string>";
6 const client = new MongoClient(uri);
7
8 try {
9 await client.connect();
10 const database = client.db("sample_mflix");
11 const collection = database.collection("movies");
12
13 const pipeline = [
14 {
15 "$vectorSearch": {
16 "index": "autoembed_index",
17 "path": "fullplot",
18 "query": {
19 "text": "journey through the country side"
20 },
21 "numCandidates": 100,
22 "limit": 10
23 }
24 },
25 {
26 "$project": {
27 "_id": 0,
28 "title": 1,
29 "fullplot": 1,
30 "score": { "$meta": "vectorSearchScore" }
31 }
32 }
33 ];
34
35 const cursor = collection.aggregate(pipeline);
36 await cursor.forEach(doc => console.log(doc));
37 } finally {
38 await client.close();
39 }
40}
41
42main().catch(console.error);

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4
node run-query.js
1{
2 title: 'Lad: A Yorkshire Story',
3 fullplot: 'The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.',
4 score: 0.504997968673706
5}
6{
7 title: 'The Land Beyond the Sunset',
8 fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.",
9 score: 0.5045041441917419
10}
11{
12 title: 'The Land Beyond the Sunset',
13 fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.",
14 score: 0.5045022964477539
15}
16{
17 title: 'The Mourning Forest',
18 fullplot: 'A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.',
19 score: 0.5043178796768188
20}
21{
22 title: 'Sleep Furiously',
23 fullplot: "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.",
24 score: 0.5042794346809387
25}
26{
27 title: 'Robinson in Space',
28 fullplot: 'Robinson is commissioned to investigate the unspecified "problem of England." The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.',
29 score: 0.5041840672492981
30}
31{
32 title: 'The Banishment',
33 fullplot: 'A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.',
34 score: 0.5041588544845581
35}
36{
37 title: 'The Village Had No Walls',
38 fullplot: 'A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.',
39 score: 0.5041133165359497
40}
41{
42 title: 'Travelers and Magicians',
43 fullplot: "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?",
44 score: 0.5040709972381592
45}
46{
47 title: 'Sweetgrass',
48 fullplot: 'In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.',
49 score: 0.5040245652198792
50}
1
2
run-query.py
1import pymongo
2
3client = pymongo.MongoClient("<connection-string>")
4collection = client["sample_mflix"]["movies"]
5
6result = collection.aggregate([
7 {
8 "$vectorSearch": {
9 "index": "autoembed_index",
10 "path": "fullplot",
11 "query": {
12 "text": "journey through the country side"
13 },
14 "numCandidates": 100,
15 "limit": 10
16 }
17 },
18 {
19 "$project": {
20 "_id": 0,
21 "title": 1,
22 "fullplot": 1,
23 "score": { "$meta": "vectorSearchScore" }
24 }
25 }
26])
27
28for i in result:
29 print(i)

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4
python run-query.py
1{'title': 'Lad: A Yorkshire Story', 'fullplot': 'The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.', 'score': 0.504997968673706}
2{'title': 'The Land Beyond the Sunset', 'fullplot': "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", 'score': 0.5045041441917419}
3{'title': 'The Land Beyond the Sunset', 'fullplot': "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", 'score': 0.5045022964477539}
4{'title': 'The Mourning Forest', 'fullplot': 'A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.', 'score': 0.5043178796768188}
5{'title': 'Sleep Furiously', 'fullplot': "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", 'score': 0.5042794346809387}
6{'title': 'Robinson in Space', 'fullplot': 'Robinson is commissioned to investigate the unspecified "problem of England." The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.', 'score': 0.5041840672492981}
7{'title': 'The Banishment', 'fullplot': 'A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.', 'score': 0.5041588544845581}
8{'title': 'The Village Had No Walls', 'fullplot': 'A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.', 'score': 0.5041133165359497}
9{'title': 'Travelers and Magicians', 'fullplot': "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", 'score': 0.5040709972381592}
10{'title': 'Sweetgrass', 'fullplot': 'In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.', 'score': 0.5040245652198792}
1
  1. Create a file named atlas_vector_search_quick_start.cpp.

  2. Copy and paste the following sample query into the atlas_vector_search_quick_start.cpp file:

    atlas_vector_search_quick_start.cpp
    1#include <bsoncxx/builder/basic/document.hpp>
    2#include <bsoncxx/json.hpp>
    3#include <iostream>
    4#include <mongocxx/client.hpp>
    5#include <mongocxx/instance.hpp>
    6#include <mongocxx/pipeline.hpp>
    7#include <mongocxx/uri.hpp>
    8
    9using bsoncxx::builder::basic::kvp;
    10using bsoncxx::builder::basic::make_document;
    11
    12int main() {
    13 try {
    14 mongocxx::instance inst{};
    15
    16 // Replace the placeholder with your connection string
    17 const auto uri = mongocxx::uri{"<connection-string>"};
    18
    19 // Connect to your cluster
    20 auto client = mongocxx::client{uri};
    21 auto db = client["sample_mflix"];
    22 auto collection = db["movies"];
    23
    24 // Define the pipeline with vectorSearch query options
    25 mongocxx::pipeline stages;
    26
    27 stages
    28 .append_stage(make_document(kvp(
    29 "$vectorSearch",
    30 make_document(
    31 kvp("index", "autoembed_index"), kvp("path", "fullplot"),
    32 kvp("query", make_document(kvp(
    33 "text", "journey through the country side"))),
    34 kvp("numCandidates", 100), kvp("model", "voyage-4"),
    35 kvp("limit", 10)))))
    36 .project(make_document(
    37 kvp("_id", 0), kvp("title", 1), kvp("fullplot", 1),
    38 kvp("score", make_document(kvp("$meta", "vectorSearchScore")))));
    39
    40 auto cursor = collection.aggregate(stages);
    41
    42 for (auto&& doc : cursor) {
    43 std::cout << bsoncxx::to_json(doc) << std::endl;
    44 }
    45 } catch (const std::exception& e) {
    46 std::cout << "Exception: " << e.what() << std::endl;
    47 }
    48 return 0;
    49}

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

3
  1. Replace the vector_index.cpp file name in your CMakeLists.txt file with your new atlas_vector_search_quick_start.cpp filename.

  2. Prepare the project.

    cmake -B build
  3. Build the app.

    cmake --build build
  4. Execute the app to run the query.

    ./query_quick_start
    1{ "title" : "Lad: A Yorkshire Story", "fullplot" : "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score" : 0.50499069690704345703 }
    2{ "title" : "The Mourning Forest", "fullplot" : "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score" : 0.50432574748992919922 }
    3{ "title" : "Sleep Furiously", "fullplot" : "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score" : 0.50427448749542236328 }
    4{ "title" : "Robinson in Space", "fullplot" : "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score" : 0.5041942596435546875 }
    5{ "title" : "The Banishment", "fullplot" : "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score" : 0.50416898727416992188 }
    6{ "title" : "The Village Had No Walls", "fullplot" : "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score" : 0.50411427021026611328 }
    7{ "title" : "Travelers and Magicians", "fullplot" : "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score" : 0.5040524601936340332 }
    8{ "fullplot" : "Seeking escape from his stalled relationship and unhappy place in the world, a recently pink-slipped music teacher sets out to hike Kentucky's Sheltowee Trace Trail. Among the verdant hills of Appalachia, he encounters various strange characters and becomes the reluctant companion of a gregarious father and son who ultimately help him rediscover what he's been missing.", "title" : "Pilgrim Song", "score" : 0.50402408838272094727 }
    9{ "title" : "The Earthling", "fullplot" : "Patrick Foley has been on the move all his life. Tired of drifting, he wants to spend his last days in an isolated Australian valley where he grew up. On his difficult journey he meets Shawn, a little desperate city-boy whose parents were killed in an accident in this remote inhospitable territory. Being unable to accompany the boy back to the civilized world he reluctantly takes him with him on his trip to that valley and teaches him in a rugged way how to survive ...", "score" : 0.50400221347808837891 }
    10{ "title" : "The Garden", "fullplot" : "Jakub's life arrived at a dead-end. He leaves his job, and gets into conflict with his father. The trouble just grows by his relation with a married woman. Breaking out, Jakub realizes the pleasures of the countryside in the old garden of his grandfather. He finds true love with an angel, and encounters various exciting moments of his new free life. Strange visitors arrive, and he wont get back to town anymore.", "score" : 0.50392138957977294922 }

Note

Vector Search Index supports both asynchronous and synchronous runtimes. In the following steps, select your preferred runtime to learn how to create a Vector Search Index for it.

1

Select the tab for the runtime that you use and run the following commands to add the required dependencies:

cargo add mongodb
cargo add tokio --features full
cargo add futures

For further information about Rust with MongoDB, see the MongoDB Rust Driver documentation.

2

In the /src directory of your project, create a file named vector_query.rs, then copy and paste the following sample query into the file.

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

vector_query.rs
1use mongodb::{
2 bson::{Document, doc},
3 Client
4};
5use futures::TryStreamExt;
6
7#[tokio::main]
8pub(crate) async fn auto_embed_query() -> mongodb::error::Result<()> {
9 // Replace the placeholder with your Atlas connection string
10 let client = Client::with_uri_str("<connection-string>").await?;
11
12 let pipeline = vec! [
13 doc! {
14 "$vectorSearch": doc! {
15 "index": "autoembed_index",
16 "path": "fullplot",
17 "query": doc! {
18 "text": "journey through the country side"
19 },
20 "numCandidates": 100,
21 "model": "voyage-4",
22 "limit": 10
23 }
24 },
25 doc! {
26 "$project": doc! {
27 "_id": 0,
28 "title": 1,
29 "fullplot": 1,
30 "score": doc! { "$meta": "vectorSearchScore"
31 }
32 }
33 }
34 ];
35 let coll = client.database("sample_mflix").collection::<Document>("movies");
36 let mut results = coll.aggregate(pipeline).await?;
37 while let Some(result) = results.try_next().await? {
38 println!("{}", result);
39 }
40 Ok(())
41}
3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
mod vector_query;
fn main() -> mongodb::error::Result<()> {
vector_query::auto_embed_query()
}
5
cargo run
1{ "title": "Lad: A Yorkshire Story", "fullplot": "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score": 0.5049906969070435 }
2{ "title": "The Mourning Forest", "fullplot": "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score": 0.5043257474899292 }
3{ "title": "Sleep Furiously", "fullplot": "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score": 0.5042744874954224 }
4{ "title": "Robinson in Space", "fullplot": "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score": 0.5041942596435547 }
5{ "title": "The Banishment", "fullplot": "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score": 0.5041689872741699 }
6{ "title": "The Village Had No Walls", "fullplot": "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score": 0.5041142702102661 }
7{ "title": "Travelers and Magicians", "fullplot": "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score": 0.504052460193634 }
8{ "fullplot": "Seeking escape from his stalled relationship and unhappy place in the world, a recently pink-slipped music teacher sets out to hike Kentucky's Sheltowee Trace Trail. Among the verdant hills of Appalachia, he encounters various strange characters and becomes the reluctant companion of a gregarious father and son who ultimately help him rediscover what he's been missing.", "title": "Pilgrim Song", "score": 0.504024088382721 }
9{ "title": "The Earthling", "fullplot": "Patrick Foley has been on the move all his life. Tired of drifting, he wants to spend his last days in an isolated Australian valley where he grew up.On his difficult journey he meets Shawn, a little desperate city-boy whose parents were killed in an accident in this remote inhospitable territory. Being unable to accompany the boy back to the civilized world he reluctantly takes him with him on his trip to that valley and teaches him in a rugged way how to survive ...", "score": 0.503984808921814 }
10{ "title": "Oyster Farmer", "fullplot": "Jack Flange leaves the big city for a respite in Australia's Hawkesbury River region, where generations of oyster fishermen (and maybe one woman) havemade a living, built histories, and piled up grievances. Jack finds a small-town mentality, with pluses and minuses. There's also a recent burglary and lots of missing cash. Jack gets a job oystering; his boss is separated from a woman of invention, Jack's attracted to a chambermaid turned letter carrier, and there are plenty of mine fields for a city boy to step through. Jack also has a sister, who's ill, to worry about. It's a river journey of self discovery. Is he passing through, or has he found home?", "score": 0.50397789478302 }
1

On the Database screen, click the sample_airbnb database, then click the listingsAndReviews collection.

2

To run this query in MongoDB Compass:

  1. Click the Aggregations tab.

  2. Click </> Text to switch to JSON view.

  3. Copy and paste to run the following query:

    1[
    2 {
    3 "$vectorSearch": {
    4 "index": "autoembed_index",
    5 "path": "fullplot",
    6 "query": {
    7 "text": "journey through the country side"
    8 },
    9 "numCandidates": 100,
    10 "limit": 10
    11 }
    12 },
    13 {
    14 "$project": {
    15 "_id": 0,
    16 "title": 1,
    17 "fullplot": 1,
    18 "score": { "$meta": "vectorSearchScore" }
    19 }
    20 }
    21]
    1title: "Lad: A Yorkshire Story"
    2fullplot: "The Yorkshire Dales provides the backdrop for the story of a young lad…"
    3score: 0.504997968673706
    4
    5title: "The Land Beyond the Sunset"
    6fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother …"
    7score: 0.5045041441917419
    8
    9title: "The Land Beyond the Sunset"
    10fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother …"
    11score: 0.5045022964477539
    12
    13title: "The Mourning Forest"
    14fullplot: "A care-giver at a small retirement home takes one of her patients for …"
    15score: 0.5043178796768188
    16
    17title: "Sleep Furiously"
    18fullplot: "Set in a small farming community in mid Wales, a place where Koppel's …"
    19score: 0.5042794346809387
    20
    21title: "Robinson in Space"
    22fullplot: "Robinson is commissioned to investigate the unspecified "problem of En…"
    23score: 0.5041840672492981
    24
    25title: "The Banishment"
    26fullplot: "A trip to the pastoral countryside reveals a dark, sinister reality fo…"
    27score: 0.5041588544845581
    28
    29title: "The Village Had No Walls"
    30fullplot: "A young man takes a journey on a cart through jungles to reach the sma…"
    31score: 0.5041133165359497
    32
    33title: "Travelers and Magicians"
    34fullplot: "The two men embark on parallel, if separate, journeys. Their yearning …"
    35score: 0.5040709972381592
    36
    37title: "Sweetgrass"
    38fullplot: "In the summer of 2003, a group of shepherds took a herd of sheep one f…"
    39score: 0.5040245652198792
    40

    For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

1

Copy and paste the following sample query into your terminal and then run it using mongosh.

1db.movies.aggregate([
2 {
3 "$vectorSearch": {
4 "index": "autoembed_index",
5 "path": "fullplot",
6 "query": {
7 "text": "journey through the country side"
8 },
9 "numCandidates": 100,
10 "model": "voyage-4",
11 "limit": 10
12 }
13 },
14 {
15 "$project": {
16 "_id": 0,
17 "title": 1,
18 "fullplot": 1,
19 "score": {"$meta": "vectorSearchScore"}
20 }
21 }
22])
1[
2 {
3 title: 'Lad: A Yorkshire Story',
4 fullplot: 'The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.',
5 score: 0.771453320980072
6 },
7 {
8 title: 'Sleep Furiously',
9 fullplot: "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.",
10 score: 0.7415832281112671
11 },
12 {
13 title: 'The Mourning Forest',
14 fullplot: 'A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.',
15 score: 0.7365885376930237
16 },
17 {
18 title: 'The Banishment',
19 fullplot: 'A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.',
20 score: 0.7326775789260864
21 },
22 {
23 title: 'Robinson in Space',
24 fullplot: 'Robinson is commissioned to investigate the unspecified "problem of England." The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.',
25 score: 0.7297798991203308
26 },
27 {
28 title: 'The Village Had No Walls',
29 fullplot: 'A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.',
30 score: 0.7290745973587036
31 },
32 {
33 fullplot: "Seeking escape from his stalled relationship and unhappy place in the world, a recently pink-slipped music teacher sets out to hike Kentucky's Sheltowee Trace Trail. Among the verdant hills of Appalachia, he encounters various strange characters and becomes the reluctant companion of a gregarious father and son who ultimately help him rediscover what he's been missing.",
34 title: 'Pilgrim Song',
35 score: 0.7271398305892944
36 },
37 {
38 title: 'Oyster Farmer',
39 fullplot: "Jack Flange leaves the big city for a respite in Australia's Hawkesbury River region, where generations of oyster fishermen (and maybe one woman) have made a living, built histories, and piled up grievances. Jack finds a small-town mentality, with pluses and minuses. There's also a recent burglary and lots of missing cash. Jack gets a job oystering; his boss is separated from a woman of invention, Jack's attracted to a chambermaid turned letter carrier, and there are plenty of mine fields for a city boy to step through. Jack also has a sister, who's ill, to worry about. It's a river journey of self discovery. Is he passing through, or has he found home?",
40 score: 0.726546049118042
41 },
42 {
43 title: 'Travelers and Magicians',
44 fullplot: "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?",
45 score: 0.7238565683364868
46 },
47 {
48 title: 'The Earthling',
49 fullplot: 'Patrick Foley has been on the move all his life. Tired of drifting, he wants to spend his last days in an isolated Australian valley where he grew up. On his difficult journey he meets Shawn, a little desperate city-boy whose parents were killed in an accident in this remote inhospitable territory. Being unable to accompany the boy back to the civilized world he reluctantly takes him with him on his trip to that valley and teaches him in a rugged way how to survive ...',
50 score: 0.7230214476585388
51 }
52]

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

1

Copy and paste the following code into the Program.cs file in your VectorSearch directory, replacing the existing contents:

Program.cs
1using MongoDB.Bson;
2using MongoDB.Driver;
3
4var connectionString = "<connection string>";
5var client = new MongoClient(connectionString);
6var database = client.GetDatabase("sample_mflix");
7var collection = database.GetCollection<BsonDocument>("movies");
8
9var pipeline = new[]
10{
11 new BsonDocument("$vectorSearch", new BsonDocument
12 {
13 { "index", "autoembed_index" },
14 { "path", "fullplot" },
15 { "query", new BsonDocument("text", "journey through the country side") },
16 { "numCandidates", 100 },
17 { "model", "voyage-4" },
18 { "limit", 10 }
19 }),
20 new BsonDocument("$project", new BsonDocument
21 {
22 { "_id", 0 },
23 { "title", 1 },
24 { "fullplot", 1 },
25 { "score", new BsonDocument("$meta", "vectorSearchScore") }
26 })
27};
28
29var results = collection.Aggregate<BsonDocument>(pipeline).ToList();
30
31foreach (var result in results)
32{
33 Console.WriteLine(result.ToJson());
34}

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

2

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

3
dotnet run
1{ "title" : "Lad: A Yorkshire Story", "fullplot" : "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score" : 0.50499796867370605 }
2{ "title" : "The Land Beyond the Sunset", "fullplot" : "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score" : 0.50450414419174194 }
3{ "title" : "The Land Beyond the Sunset", "fullplot" : "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score" : 0.50450229644775391 }
4{ "title" : "The Mourning Forest", "fullplot" : "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score" : 0.50431787967681885 }
5{ "title" : "Sleep Furiously", "fullplot" : "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score" : 0.50427943468093872 }
6{ "title" : "Robinson in Space", "fullplot" : "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score" : 0.5041840672492981 }
7{ "title" : "The Banishment", "fullplot" : "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score" : 0.50415885448455811 }
8{ "title" : "The Village Had No Walls", "fullplot" : "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score" : 0.50411331653594971 }
9{ "title" : "Travelers and Magicians", "fullplot" : "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score" : 0.50407099723815918 }
10{ "title" : "Sweetgrass", "fullplot" : "In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.", "score" : 0.50402456521987915 }
1

Create a new Go file to connect to your deployment and query the auto-embedding MongoDB Vector Search index that you created in the previous step.

2
main.go
1package main
2
3import (
4 "context"
5 "encoding/json"
6 "fmt"
7 "log"
8 "time"
9
10 "go.mongodb.org/mongo-driver/v2/bson"
11 "go.mongodb.org/mongo-driver/v2/mongo"
12 "go.mongodb.org/mongo-driver/v2/mongo/options"
13)
14
15const (
16 indexName = "autoembed_index"
17)
18
19func main() {
20 // Replace with your MongoDB connection string.
21 uri := "<connection-string>"
22
23 // Create a context with a timeout for querying.
24 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
25 defer cancel()
26
27 // Connect to your deployment.
28 client, err := mongo.Connect(options.Client().ApplyURI(uri))
29 if err != nil {
30 log.Fatalf("Failed to connect to MongoDB: %v", err)
31 }
32 defer func() {
33 if err := client.Disconnect(context.Background()); err != nil {
34 log.Printf("Error disconnecting client: %v", err)
35 }
36 }()
37
38 // Access your database and collection.
39 db := client.Database("sample_mflix")
40 coll := db.Collection("movies")
41
42 // Run a $vectorSearch query using the auto-embedding index.
43 if err := runVectorSearchQuery(ctx, coll); err != nil {
44 log.Fatalf("Failed to run $vectorSearch query: %v", err)
45 }
46}
47
48func runVectorSearchQuery(ctx context.Context, coll *mongo.Collection) error {
49 pipeline := mongo.Pipeline{
50 {{
51 "$vectorSearch", bson.D{
52 {"index", indexName},
53 {"path", "fullplot"},
54 {"query", bson.D{
55 {"text", "journey through the country side"},
56 }},
57 {"numCandidates", 100},
58 {"limit", 10},
59 },
60 }},
61 {{
62 "$project", bson.D{
63 {"_id", 0},
64 {"title", 1},
65 {"fullplot", 1},
66 {"score", bson.D{{"$meta", "vectorSearchScore"}}},
67 },
68 }},
69 }
70
71 cursor, err := coll.Aggregate(ctx, pipeline)
72 if err != nil {
73 return fmt.Errorf("aggregate: %w", err)
74 }
75 defer cursor.Close(ctx)
76
77 fmt.Println("Query results:")
78 for cursor.Next(ctx) {
79 var doc bson.M
80 if err := cursor.Decode(&doc); err != nil {
81 return fmt.Errorf("decode result: %w", err)
82 }
83
84 // Marshal each document to compact JSON (Extended JSON for Decimal128, etc.).
85 data, err := json.Marshal(doc)
86 if err != nil {
87 return fmt.Errorf("marshal result to JSON: %w", err)
88 }
89
90 fmt.Println(string(data))
91 }
92 return cursor.Err()
93}

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4

Run the following command to query your collection:

go run main.go
Query results:
{"fullplot":"The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.","score":0.504997968673706,"title":"Lad: A Yorkshire Story"}
{"fullplot":"Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.","score":0.5045041441917419,"title":"The Land Beyond the Sunset"}
{"fullplot":"Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.","score":0.5045022964477539,"title":"The Land Beyond the Sunset"}
{"fullplot":"A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.","score":0.5043178796768188,"title":"The Mourning Forest"}
{"fullplot":"Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.","score":0.5042794346809387,"title":"Sleep Furiously"}
{"fullplot":"Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.","score":0.5041840672492981,"title":"Robinson in Space"}
{"fullplot":"A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.","score":0.5041588544845581,"title":"The Banishment"}
{"fullplot":"A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.","score":0.5041133165359497,"title":"The Village Had No Walls"}
{"fullplot":"The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?","score":0.5040709972381592,"title":"Travelers and Magicians"}
{"fullplot":"In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.","score":0.5040245652198792,"title":"Sweetgrass"}
1
2
runQuery.java
1import static com.mongodb.client.model.Aggregates.*;
2import static com.mongodb.client.model.Projections.*;
3import static com.mongodb.client.model.search.SearchPath.fieldPath;
4import static com.mongodb.client.model.search.VectorSearchOptions.approximateVectorSearchOptions;
5import static com.mongodb.client.model.search.VectorSearchQuery.textQuery;
6import static java.util.Arrays.asList;
7
8import com.mongodb.client.MongoClient;
9import com.mongodb.client.MongoClients;
10import com.mongodb.client.MongoCollection;
11import com.mongodb.client.MongoDatabase;
12import org.bson.Document;
13import org.bson.conversions.Bson;
14
15import java.util.ArrayList;
16import java.util.List;
17
18public class Query {
19 public static void main(String[] args) {
20 // Replace the placeholder with your connection string
21 String uri = "<connectionString>";
22
23 try (MongoClient client = MongoClients.create(uri)) {
24 MongoDatabase database = client.getDatabase("sample_mflix");
25 MongoCollection<Document> collection = database.getCollection("movies");
26
27 List<Bson> pipeline = asList(
28 vectorSearch(
29 fieldPath("fullplot"),
30 textQuery("journey through the country side"),
31 "autoembed_index",
32 10L,
33 approximateVectorSearchOptions(100L)
34 ),
35 project(
36 fields(
37 excludeId(),
38 include("title", "fullplot"),
39 computed("score", new Document("$meta", "vectorSearchScore"))
40 )
41 )
42 );
43
44 List<Document> results = collection.aggregate(pipeline).into(new ArrayList<>());
45 for (Document doc : results) {
46 System.out.println(doc.toJson());
47 }
48 }
49 }
50}

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4
javac runQuery.java
java runQuery
1{"title": "Lad: A Yorkshire Story", "fullplot": "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score": 0.504997968673706}
2{"title": "The Land Beyond the Sunset", "fullplot": "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score": 0.5045041441917419}
3{"title": "The Land Beyond the Sunset", "fullplot": "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", "score": 0.5045022964477539}
4{"title": "The Mourning Forest", "fullplot": "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score": 0.5043178796768188}
5{"title": "Sleep Furiously", "fullplot": "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score": 0.5042794346809387}
6{"title": "Robinson in Space", "fullplot": "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score": 0.5041840672492981}
7{"title": "The Banishment", "fullplot": "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score": 0.5041588544845581}
8{"title": "The Village Had No Walls", "fullplot": "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score": 0.5041133165359497}
9{"title": "Travelers and Magicians", "fullplot": "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score": 0.5040709972381592}
10{"title": "Sweetgrass", "fullplot": "In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.", "score": 0.5040245652198792}
1
2
run-query.js
1const { MongoClient } = require("mongodb");
2
3async function main() {
4 // Replace the placeholder with your connection string
5 const uri = "<connection-string>";
6 const client = new MongoClient(uri);
7
8 try {
9 await client.connect();
10 const database = client.db("sample_mflix");
11 const collection = database.collection("movies");
12
13 const pipeline = [
14 {
15 "$vectorSearch": {
16 "index": "autoembed_index",
17 "path": "fullplot",
18 "query": {
19 "text": "journey through the country side"
20 },
21 "numCandidates": 100,
22 "limit": 10
23 }
24 },
25 {
26 "$project": {
27 "_id": 0,
28 "title": 1,
29 "fullplot": 1,
30 "score": { "$meta": "vectorSearchScore" }
31 }
32 }
33 ];
34
35 const cursor = collection.aggregate(pipeline);
36 await cursor.forEach(doc => console.log(doc));
37 } finally {
38 await client.close();
39 }
40}
41
42main().catch(console.error);

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4
node run-query.js
1{
2 title: 'Lad: A Yorkshire Story',
3 fullplot: 'The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.',
4 score: 0.504997968673706
5}
6{
7 title: 'The Land Beyond the Sunset',
8 fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.",
9 score: 0.5045041441917419
10}
11{
12 title: 'The Land Beyond the Sunset',
13 fullplot: "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.",
14 score: 0.5045022964477539
15}
16{
17 title: 'The Mourning Forest',
18 fullplot: 'A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.',
19 score: 0.5043178796768188
20}
21{
22 title: 'Sleep Furiously',
23 fullplot: "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.",
24 score: 0.5042794346809387
25}
26{
27 title: 'Robinson in Space',
28 fullplot: 'Robinson is commissioned to investigate the unspecified "problem of England." The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.',
29 score: 0.5041840672492981
30}
31{
32 title: 'The Banishment',
33 fullplot: 'A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.',
34 score: 0.5041588544845581
35}
36{
37 title: 'The Village Had No Walls',
38 fullplot: 'A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.',
39 score: 0.5041133165359497
40}
41{
42 title: 'Travelers and Magicians',
43 fullplot: "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?",
44 score: 0.5040709972381592
45}
46{
47 title: 'Sweetgrass',
48 fullplot: 'In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.',
49 score: 0.5040245652198792
50}
1
2
run-query.py
1import pymongo
2
3client = pymongo.MongoClient("<connection-string>")
4collection = client["sample_mflix"]["movies"]
5
6result = collection.aggregate([
7 {
8 "$vectorSearch": {
9 "index": "autoembed_index",
10 "path": "fullplot",
11 "query": {
12 "text": "journey through the country side"
13 },
14 "numCandidates": 100,
15 "limit": 10
16 }
17 },
18 {
19 "$project": {
20 "_id": 0,
21 "title": 1,
22 "fullplot": 1,
23 "score": { "$meta": "vectorSearchScore" }
24 }
25 }
26])
27
28for i in result:
29 print(i)

For details on all the MongoDB Vector Search query settings for Automated Embedding, see $vectorSearch syntax.

3

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

4
python run-query.py
1{'title': 'Lad: A Yorkshire Story', 'fullplot': 'The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.', 'score': 0.504997968673706}
2{'title': 'The Land Beyond the Sunset', 'fullplot': "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", 'score': 0.5045041441917419}
3{'title': 'The Land Beyond the Sunset', 'fullplot': "Thanks to the Fresh Air Fund, a slum child escapes his drunken mother for a day's outing in the country. Upon arriving, he and the other children are told a story about a mythical land of no pain. Rather then return to the slum at day's end, the lad seeks to journey to that beautiful land beyond the sunset.", 'score': 0.5045022964477539}
4{'title': 'The Mourning Forest', 'fullplot': 'A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.', 'score': 0.5043178796768188}
5{'title': 'Sleep Furiously', 'fullplot': "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", 'score': 0.5042794346809387}
6{'title': 'Robinson in Space', 'fullplot': 'Robinson is commissioned to investigate the unspecified "problem of England." The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.', 'score': 0.5041840672492981}
7{'title': 'The Banishment', 'fullplot': 'A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.', 'score': 0.5041588544845581}
8{'title': 'The Village Had No Walls', 'fullplot': 'A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.', 'score': 0.5041133165359497}
9{'title': 'Travelers and Magicians', 'fullplot': "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", 'score': 0.5040709972381592}
10{'title': 'Sweetgrass', 'fullplot': 'In the summer of 2003, a group of shepherds took a herd of sheep one final time through the Beartooth Mountains of Montana, in the extreme northwest of the United States. It was a journey of almost 300 kilometers through expansive green valleys, by fields of snow, and across hazardous, narrow ridges - a journey brimming with challenges. The aging shepherds do their very best to keep the hundreds of sheep together; the panoramic high mountains are teeming with hungry wolves and grizzly bears.', 'score': 0.5040245652198792}
1
  1. Create a file named atlas_vector_search_quick_start.cpp.

  2. Copy and paste the following sample query into the atlas_vector_search_quick_start.cpp file:

    atlas_vector_search_quick_start.cpp
    1#include <bsoncxx/builder/basic/document.hpp>
    2#include <bsoncxx/json.hpp>
    3#include <iostream>
    4#include <mongocxx/client.hpp>
    5#include <mongocxx/instance.hpp>
    6#include <mongocxx/pipeline.hpp>
    7#include <mongocxx/uri.hpp>
    8
    9using bsoncxx::builder::basic::kvp;
    10using bsoncxx::builder::basic::make_document;
    11
    12int main() {
    13 try {
    14 mongocxx::instance inst{};
    15
    16 // Replace the placeholder with your connection string
    17 const auto uri = mongocxx::uri{"<connection-string>"};
    18
    19 // Connect to your cluster
    20 auto client = mongocxx::client{uri};
    21 auto db = client["sample_mflix"];
    22 auto collection = db["movies"];
    23
    24 // Define the pipeline with vectorSearch query options
    25 mongocxx::pipeline stages;
    26
    27 stages
    28 .append_stage(make_document(kvp(
    29 "$vectorSearch",
    30 make_document(
    31 kvp("index", "autoembed_index"), kvp("path", "fullplot"),
    32 kvp("query", make_document(kvp(
    33 "text", "journey through the country side"))),
    34 kvp("numCandidates", 100), kvp("model", "voyage-4"),
    35 kvp("limit", 10)))))
    36 .project(make_document(
    37 kvp("_id", 0), kvp("title", 1), kvp("fullplot", 1),
    38 kvp("score", make_document(kvp("$meta", "vectorSearchScore")))));
    39
    40 auto cursor = collection.aggregate(stages);
    41
    42 for (auto&& doc : cursor) {
    43 std::cout << bsoncxx::to_json(doc) << std::endl;
    44 }
    45 } catch (const std::exception& e) {
    46 std::cout << "Exception: " << e.what() << std::endl;
    47 }
    48 return 0;
    49}

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

2

Ensure that your connection string includes your database user's credentials. To learn more, see Connect to a Cluster via Client Libraries.

3
  1. Replace the vector_index.cpp file name in your CMakeLists.txt file with your new atlas_vector_search_quick_start.cpp filename.

  2. Prepare the project.

    cmake -B build
  3. Build the app.

    cmake --build build
  4. Execute the app to run the query.

    ./query_quick_start
    1{ "title" : "Lad: A Yorkshire Story", "fullplot" : "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score" : 0.50499069690704345703 }
    2{ "title" : "The Mourning Forest", "fullplot" : "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score" : 0.50432574748992919922 }
    3{ "title" : "Sleep Furiously", "fullplot" : "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score" : 0.50427448749542236328 }
    4{ "title" : "Robinson in Space", "fullplot" : "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score" : 0.5041942596435546875 }
    5{ "title" : "The Banishment", "fullplot" : "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score" : 0.50416898727416992188 }
    6{ "title" : "The Village Had No Walls", "fullplot" : "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score" : 0.50411427021026611328 }
    7{ "title" : "Travelers and Magicians", "fullplot" : "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score" : 0.5040524601936340332 }
    8{ "fullplot" : "Seeking escape from his stalled relationship and unhappy place in the world, a recently pink-slipped music teacher sets out to hike Kentucky's Sheltowee Trace Trail. Among the verdant hills of Appalachia, he encounters various strange characters and becomes the reluctant companion of a gregarious father and son who ultimately help him rediscover what he's been missing.", "title" : "Pilgrim Song", "score" : 0.50402408838272094727 }
    9{ "title" : "The Earthling", "fullplot" : "Patrick Foley has been on the move all his life. Tired of drifting, he wants to spend his last days in an isolated Australian valley where he grew up. On his difficult journey he meets Shawn, a little desperate city-boy whose parents were killed in an accident in this remote inhospitable territory. Being unable to accompany the boy back to the civilized world he reluctantly takes him with him on his trip to that valley and teaches him in a rugged way how to survive ...", "score" : 0.50400221347808837891 }
    10{ "title" : "The Garden", "fullplot" : "Jakub's life arrived at a dead-end. He leaves his job, and gets into conflict with his father. The trouble just grows by his relation with a married woman. Breaking out, Jakub realizes the pleasures of the countryside in the old garden of his grandfather. He finds true love with an angel, and encounters various exciting moments of his new free life. Strange visitors arrive, and he wont get back to town anymore.", "score" : 0.50392138957977294922 }

Note

Vector Search Index supports both asynchronous and synchronous runtimes. In the following steps, select your preferred runtime to learn how to create a Vector Search Index for it.

1

Select the tab for the runtime that you use and run the following commands to add the required dependencies:

cargo add mongodb
cargo add tokio --features full
cargo add futures

For further information about Rust with MongoDB, see the MongoDB Rust Driver documentation.

2

In the /src directory of your project, create a file named vector_query.rs, then copy and paste the following sample query into the file.

This query uses the $vectorSearch stage to:

  • Generate vector embeddings for the query text using the embedding model, voyage-4, which is the same model specified in the index definition. You can use any compatible embedding model in the query.

  • Perform a semantic search for the query text using the vector embeddings generated using the embedding model, voyage-4, specified in the query.

  • Consider up to 100 most similar movie plots and return the top 10 results.

It uses the $project stage to:

  • Only include the movie fullplot and title fields in the results.

  • Add a score field to show the relevance of each result to the search term.

To learn more about this pipeline stage, see Run Vector Search ANN and ENN Queries.

vector_query.rs
1use mongodb::{
2 bson::{Document, doc},
3 Client
4};
5use futures::TryStreamExt;
6
7#[tokio::main]
8pub(crate) async fn auto_embed_query() -> mongodb::error::Result<()> {
9 // Replace the placeholder with your Atlas connection string
10 let client = Client::with_uri_str("<connection-string>").await?;
11
12 let pipeline = vec! [
13 doc! {
14 "$vectorSearch": doc! {
15 "index": "autoembed_index",
16 "path": "fullplot",
17 "query": doc! {
18 "text": "journey through the country side"
19 },
20 "numCandidates": 100,
21 "model": "voyage-4",
22 "limit": 10
23 }
24 },
25 doc! {
26 "$project": doc! {
27 "_id": 0,
28 "title": 1,
29 "fullplot": 1,
30 "score": doc! { "$meta": "vectorSearchScore"
31 }
32 }
33 }
34 ];
35 let coll = client.database("sample_mflix").collection::<Document>("movies");
36 let mut results = coll.aggregate(pipeline).await?;
37 while let Some(result) = results.try_next().await? {
38 println!("{}", result);
39 }
40 Ok(())
41}
3

Replace <connection-string> with the connection string for your Atlas cluster or local Atlas deployment.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

IMPORTANT: Ensure that your connection string includes your database user's credentials. To learn more about finding your connection string, see Connect to a Cluster via Client Libraries.

4
mod vector_query;
fn main() -> mongodb::error::Result<()> {
vector_query::auto_embed_query()
}
5
cargo run
1{ "title": "Lad: A Yorkshire Story", "fullplot": "The Yorkshire Dales provides the backdrop for the story of a young lad and his elder brother as they spend a weekend roaming the countryside.", "score": 0.5049906969070435 }
2{ "title": "The Mourning Forest", "fullplot": "A care-giver at a small retirement home takes one of her patients for a drive to the country, but the two wind up stranded in a forest where they embark on an exhausting and enlightening two-day journey.", "score": 0.5043257474899292 }
3{ "title": "Sleep Furiously", "fullplot": "Set in a small farming community in mid Wales, a place where Koppel's parents - both refugees - found a home. This is a landscape and population that is changing rapidly as small scale agriculture is disappearing and the generation who inhabited a pre-mechanised world is dying out. Much influenced by his conversations with the writer Peter Handke, the film maker leads us on a poetic and profound journey into a world of endings and beginnings; a world of stuffed owls, sheep and fire.", "score": 0.5042744874954224 }
4{ "title": "Robinson in Space", "fullplot": "Robinson is commissioned to investigate the unspecified \"problem of England.\" The narrator describes his seven excursions, with the unseen Robinson, around the country. They mainly concentrate on ports, power stations, prisons, and manufacturing plants, but they also bring in various literary connections, as well as a few conventional landscapes.", "score": 0.5041942596435547 }
5{ "title": "The Banishment", "fullplot": "A trip to the pastoral countryside reveals a dark, sinister reality for a family from the city.", "score": 0.5041689872741699 }
6{ "title": "The Village Had No Walls", "fullplot": "A young man takes a journey on a cart through jungles to reach the small hamlet of Bangarwadi, inhabited by a few shepherds, peasants and some members of a criminal tribe known as the Ramoshis. The young man goes there as a teacher. After the initial trauma, he finds the milieu and the environment very inspiring and educative. But then he is transferred to some other school. What remains with him is the memory of the simple folk and their pure nature.", "score": 0.5041142702102661 }
7{ "title": "Travelers and Magicians", "fullplot": "The two men embark on parallel, if separate, journeys. Their yearning is a common one--for a better and different life. Dondup, delayed by the timeless pace of his village, is forced to hitchhike through the beautiful wild countryside of Bhutan to reach his goal. He shares the road with a monk, an apple seller, a papermaker and his beautiful young daughter, Sonam. Throughout the journey, the perceptive yet mischievous monk relates the story of Tashi. It is a mystical fable of lust, jealousy and murder, that holds up a mirror to the restless Dondup, and his blossoming attraction to the innocent Sonam. The cataclysmic conclusion of the monk's tale leaves Dondup with a dilemma--is the grass truly greener on the other side?", "score": 0.504052460193634 }
8{ "fullplot": "Seeking escape from his stalled relationship and unhappy place in the world, a recently pink-slipped music teacher sets out to hike Kentucky's Sheltowee Trace Trail. Among the verdant hills of Appalachia, he encounters various strange characters and becomes the reluctant companion of a gregarious father and son who ultimately help him rediscover what he's been missing.", "title": "Pilgrim Song", "score": 0.504024088382721 }
9{ "title": "The Earthling", "fullplot": "Patrick Foley has been on the move all his life. Tired of drifting, he wants to spend his last days in an isolated Australian valley where he grew up.On his difficult journey he meets Shawn, a little desperate city-boy whose parents were killed in an accident in this remote inhospitable territory. Being unable to accompany the boy back to the civilized world he reluctantly takes him with him on his trip to that valley and teaches him in a rugged way how to survive ...", "score": 0.503984808921814 }
10{ "title": "Oyster Farmer", "fullplot": "Jack Flange leaves the big city for a respite in Australia's Hawkesbury River region, where generations of oyster fishermen (and maybe one woman) havemade a living, built histories, and piled up grievances. Jack finds a small-town mentality, with pluses and minuses. There's also a recent burglary and lots of missing cash. Jack gets a job oystering; his boss is separated from a woman of invention, Jack's attracted to a chambermaid turned letter carrier, and there are plenty of mine fields for a city boy to step through. Jack also has a sister, who's ill, to worry about. It's a river journey of self discovery. Is he passing through, or has he found home?", "score": 0.50397789478302 }

To check the status of your MongoDB Vector Search index, use the Atlas UI to navigate to your cluster and do the following:

1

You can go the MongoDB Search page from the Search & Vector Search option, or the Data Explorer.

2
  1. In the Search & Vector Search page, locate the index to check.

  2. Check the Status field to verify the status of the index.

To check the status of your MongoDB Vector Search index, run the following command after replacing the following placeholders:

<connection-string>

Your cluster connection string.

<database-name>

The name of the database the collection.

<collection-name>

The name of the collection for which you created the index.

mongosh <connection-string>/<database-name> --eval '
db.<collection-name>.getSearchIndexes().forEach(printjson);
'

The preceding command connects to your cluster and for the specified collection in the specified database, iterates through each index on the collection and returns the index definition in JSON format.

Sample Command to Retrieve Indexes on the movies Collection
mongosh "mongodb://localhost:27017/sample_mflix" --eval '
db.movies.getSearchIndexes().forEach(printjson);
'
Sample Command to Retrieve Indexes on the movies Collection
{
id: '698d005f8bf34e5e6624d086',
name: 'vector_index',
type: 'vectorSearch',
status: 'READY',
numDocs: 21349,
latestDefinition: {
type: 'vectorSearch',
indexID: ObjectId('698d005f8bf34e5e6624d086'),
name: 'vector_index',
database: 'sample_mflix',
lastObservedCollectionName: 'movies',
collectionUUID: UUID('3920f806-ec08-46ae-a73e-8e1e191e85f5'),
numPartitions: 1,
fields: [
{
type: 'autoEmbed',
path: 'fullplot',
model: 'voyage-4',
modality: 'text'
}
],
definitionVersion: 0,
definitionVersionCreatedAt: '2026-02-11T22:19:11Z',
indexFeatureVersion: 4
}
}

To verify that MongoDB Vector Search has generated embeddings for your indexed text data, run the following command after replacing the <connection-string> placeholder with your cluster connection string:

mongosh "<connection-string>" --apiVersion 1 --eval '
print("Embeddings: " +
db.getSiblingDB("__mdb_internal_search")
.getCollectionNames()
.filter(c => /^[0-9a-f]{24}-[0-9a-f]{32}-\d+-\d+$/.test(c))
.map(c => db.getSiblingDB("__mdb_internal_search").getCollection(c).countDocuments())
.reduce((a, b) => a + b, 0)
);
'

The preceding command connects to your cluster and returns the total number of vector embeddings stored across all collections in your deployment.

This quick start focused on retrieving documents from your cluster that contain text that is semantically related to a provided query. However, you can create a vector search index on embeddings that represent any type of data that you might write to your cluster, such as images or videos.

This quick start uses the sample_mflix.embedded_movies collection which contains details about movies. In each document in the collection, the plot_embedding_voyage_3_large field contains a vector embedding that represents the string in the plot field. For more information on the schema of the documents in the collection, see Sample Mflix Dataset.

By storing your source data and its corresponding vector embeddings in the same document, you can leverage both fields for complex queries or hybrid search. You can even store vector embeddings generated from different embedding models in the same document to streamline your workflow as you test the performance of different vector embedding models for your specific use case.

This quick start uses the sample_mflix database, which contains collections with movie details.

The fullplot field in the movies collection contains text that describes the plot of the movie.

By configuring MongoDB Vector Search to automatically generate embeddings for text data in your collection, such as the fullplot field in the movies collection, you can use MongoDB Vector Search to also generate embeddings for natural language queries against the fullplot field.

This quick start uses the sample_mflix.embedded_movies collection which contains details about movies. In each document in the collection, the plot_embedding_voyage_3_large field contains a vector embedding that represents the string in the plot field. For more information on the schema of the documents in the collection, see Sample Mflix Dataset.

By storing your source data and its corresponding vector embeddings in the same document, you can leverage both fields for complex queries or hybrid search. You can even store vector embeddings generated from different embedding models in the same document to streamline your workflow as you test the performance of different vector embedding models for your specific use case.

This quick start uses the sample_mflix database, which contains collections with movie details.

The fullplot field in the movies collection contains text that describes the plot of the movie.

By configuring MongoDB Vector Search to automatically generate embeddings for text data in your collection, such as the fullplot field in the movies collection, you can use MongoDB Vector Search to also generate embeddings for natural language queries against the fullplot field. MongoDB Vector Search can use the Voyage AI API keys to generate embeddings from available Voyage AI embedding models.

This quick start uses the sample_mflix database, which contains collections with movie details.

The fullplot field in the movies collection contains text that describes the plot of the movie.

By configuring MongoDB Vector Search to automatically generate embeddings for text data in your collection, such as the fullplot field in the movies collection, you can use MongoDB Vector Search to also generate embeddings for natural language queries against the fullplot field. MongoDB Vector Search can use the Voyage AI API keys to generate embeddings from available Voyage AI embedding models.

This quick start uses the sample_mflix database, which contains collections that contains detail about movies.

The plot_embedding_voyage_3_large field in the embedded_movies collection contain the a vector embedding that represents the string in the plot field. For more information on the schema of the documents in the collection, see Sample Mflix Dataset.

By storing your source data and its corresponding vector embeddings in the same document, you can leverage both fields for complex queries or hybrid search. You can even store vector embeddings generated from different embedding models in the same document to streamline your workflow as you test the performance of different vector embedding models for your specific use case.

The vector embeddings in the sample_mflix.embedded_movies collection and in the example query were created using the Voyage AI voyage-3-large embedding model. Your embedding model choice informs the vector dimensions and vector similarity function you use in your vector search index. You can use any embedding model you like, and experiment with different models as accuracy can vary between models depending on your specific use case.

To learn how to create vector embeddings of your own data, see How to Create Vector Embeddings.

The vector embeddings for the fullplot field and the example query against the fullplot field in the sample_mflix.embedded_movies collection were created using the embedding model, voyage-4, specified in the index definition for the field. MongoDB Vector Search automatically generates embeddings for the data in the collection and the query text using paid tokens. In the Atlas UI, you can view:

  • Remaining number of free tokens in the Search & Vector Search dashboard Auto Embedding section.

  • Costs in your organization's Billing Cost Explorer page.

The vector embeddings in the sample_mflix.embedded_movies collection and in the example query were created using the Voyage AI voyage-3-large embedding model. Your choice of embedding model informs the vector dimensions and vector similarity function you use in your vector search index. You can use any embedding model you like, and experiment with different models as accuracy can vary between models depending on your specific use case.

To learn how to create vector embeddings of your own data, see How to Create Vector Embeddings.

The vector embeddings for the fullplot field and the example query against the fullplot field in the sample_mflix.embedded_movies collection were created using the Voyage AI API keys. The embeddings for the field and the query text against the field use the model, voyage-4, specified in the index definition for the field. You can use any compatible embedding model in the query.

To learn how to automatically generate vector embeddings for your data and natural language queries against your data, see How to Automatically Generate Embeddings.

The vector embeddings for the fullplot field and the example query against the fullplot field in the sample_mflix.embedded_movies collection were created using the Voyage AI API keys. The embeddings for the field and the query text against the field use the model, voyage-4, specified in the index definition for the field. You can use any compatible embedding model in the query.

To learn how to automatically generate vector embeddings for your data and natural language queries against your data, see How to Automatically Generate Embeddings.

The vector embeddings in the sample_mflix.embedded_movies collection and in the example query were created using the Voyage AI voyage-3-large embedding model. Your choice of embedding model informs the vector dimensions and vector similarity function you use in your vector search index. You can use any embedding model you like, and experiment with different models as accuracy can vary between models depending on your specific use case.

To learn how to create vector embeddings of your own data, see How to Create Vector Embeddings.

An index is a data structure that holds a subset of data from a collection's documents that improves database performance for specific queries. A vector search index points to the fields that contain your vector embeddings and includes the dimensions of your vectors as well as the function used to measure similarity between vectors of queries and vectors stored in the database.

Because the voyage-3-large embedding model used in this quick start converts data into vector embeddings with 2048 dimensions and supports the cosine function, this vector search index specifies the same number of vector dimensions and similarity function.

The autoEmbed type index configures Automated Embedding for the fullplot field using the voyage-4 embedding model in the index definition. If you don't specify an embedding model in the query, MongoDB Vector Search uses the embedding model specified in the index definition for generating embeddings for the query text.

An index is a data structure that holds a subset of data from a collection's documents that improves database performance for specific queries. A vector search index points to the fields that contain your vector embeddings and includes the dimensions of your vectors as well as the function used to measure similarity between vectors of queries and vectors stored in the database.

Because the voyage-3-large embedding model used in this quick start converts data into vector embeddings with 2048 dimensions and supports the cosine function, this vector search index specifies the same number of vector dimensions and similarity function.

An index is a data structure that holds a subset of data from a collection's documents that improves database performance for specific queries. A vector search index points to the fields that contain text that you want to configure Automated Embedding using a supported Voyage AI embedding model for.

The autoEmbed type index configures Automated Embedding for the fullplot field using the voyage-4 embedding model in the index definition.

An index is a data structure that holds a subset of data from a collection's documents that improves database performance for specific queries. A vector search index points to the fields that contain text that you want to configure Automated Embedding using a supported Voyage AI embedding model for.

The autoEmbed type index configures Automated Embedding for the fullplot field using the voyage-4 embedding model in the index definition.

An index is a data structure that holds a subset of data from a collection's documents that improves database performance for specific queries. A vector search index points to the fields that contain your vector embeddings and includes the dimensions of your vectors as well as the function used to measure similarity between vectors of queries and vectors stored in the database.

Because the voyage-3-large embedding model used in this quick start converts data into vector embeddings with 2048 dimensions and supports the cosine function, this vector search index specifies the same number of vector dimensions and similarity function.

The query you ran in this quick start is an aggregation pipeline, in which the $vectorSearch stage performs an Approximate Nearest Neighbor (ANN) search followed by a $project stage that refines the results. To see all the options for a semantic search query, including using Exact Nearest Neighbor (ENN) or how to narrow the scope of your semantic search with the filter option, see Run Vector Search Queries.