Skip to main content
Amazon DocumentDB (with MongoDB Compatibility) makes it easy to set up, operate, and scale MongoDB-compatible databases in the cloud. With Amazon DocumentDB, you can run the same application code and use the same drivers and tools that you use with MongoDB. Vector search for Amazon DocumentDB combines the flexibility and rich querying capability of a JSON-based document database with the power of vector search.
This notebook shows you how to use Amazon Document DB Vector Search to store documents in collections, create indices and perform vector search queries using approximate nearest neighbor algorithms such “cosine”, “euclidean”, and “dotProduct”. By default, DocumentDB creates Hierarchical Navigable Small World (HNSW) indexes. To learn about other supported vector index types, please refer to the document linked above. To use DocumentDB, you must first deploy a cluster. Please refer to the Developer Guide for more details. Sign Up for free to get started today.
We want to use OpenAIEmbeddings so we need to set up our OpenAI environment variables.
Now, we will load the documents into the collection, create the index, and then perform queries against the index. Please refer to the documentation if you have questions about certain parameters
The langchain-community package is no longer maintained. Examples that import from langchain_community may be outdated or broken. Use with caution.
Once the documents have been loaded and the index has been created, you can now instantiate the vector store directly and run queries against the index

Question answering