AmazonS3VectorsDocumentStore
| Mandatory init variables | vector_bucket_name, index_name: The vector bucket and index to use. dimension: The embedding dimension. |
| Optional init variables | distance_metric: "cosine" (default) or "euclidean". region_name: AWS region; otherwise uses the environment or AWS configuration. aws_access_key_id, aws_secret_access_key, aws_session_token: Credentials as Secret objects; otherwise uses the configured AWS credentials. create_bucket_and_index: Create missing resources (default: True). non_filterable_metadata_keys: Additional metadata fields excluded from query filtering. |
| API reference | Amazon S3 Vectors |
| GitHub link | https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/amazon_s3_vectors |
| Package name | amazon-s3-vectors-haystack |
Amazon S3 Vectors provides vector storage and approximate similarity search without provisioning a database server. It uses dedicated vector buckets, with indexes containing embeddings and metadata.
AmazonS3VectorsDocumentStore stores Documents, their dense embeddings, and supported metadata in a vector index. It does not provide keyword retrieval.
Installation
Install the integration:
Authentication
AmazonS3VectorsDocumentStore uses AWS for authentication. You can provide AWS credentials directly to the Document Store or use credentials configured through the AWS CLI.
To authenticate by providing credentials, pass aws_access_key_id and aws_secret_access_key as Secret arguments, along with aws_session_token for temporary credentials. Set the AWS region with region_name.
Make sure your AWS identity has the required S3 Vectors permissions.
Initialization
Provide a vector bucket name, an index name, and the embedding dimension.
from haystack import Document
from haystack_integrations.document_stores.amazon_s3_vectors import (
AmazonS3VectorsDocumentStore,
)
document_store = AmazonS3VectorsDocumentStore(
vector_bucket_name="haystack-docs-example",
index_name="documents",
dimension=3,
region_name="us-east-1",
)
document_store.write_documents(
[
Document(id="first", content="First document", embedding=[1.0, 0.0, 0.0]),
Document(id="second", content="Second document", embedding=[0.0, 1.0, 0.0]),
]
)
print(document_store.count_documents())
# >> 2
document_store.close()
To learn more about the initialization parameters, see our API docs.
- Writes overwrite documents with the same ID;
DuplicatePolicy.FAILandDuplicatePolicy.SKIPare not enforced. filter_documents()andcount_documents()scan the index and can be slow. Prefer the retriever for similarity search.
See the AWS limitations for service quotas and metadata limits.
Supported Retrievers
- AmazonS3VectorsEmbeddingRetriever: retrieves documents using a query embedding, with optional metadata filters.