Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

AmazonS3VectorsEmbeddingRetriever

Retrieve documents from an AmazonS3VectorsDocumentStore using vector similarity search. Use this component in query pipelines to find semantically similar documents stored in Amazon S3 Vectors, the AWS vector storage service built on Amazon S3.

::: info Embedding Models in Pipelines and Indexes

The embedding model you use to embed documents in your index must be the same as the embedding model you use to embed the query in your pipeline.

This means the embedders for your indexes and pipelines must match. For example, if you use CohereDocumentEmbedder to embed your documents, you should use CohereTextEmbedder with the same model to embed your queries.

If the query model's name differs from the index model's name, for example an ONNX variant of the same model, the platform shows a warning in the Issues panel but still lets you save and deploy the pipeline. Make sure both models produce compatible embeddings. If the index has no embedding model, validation fails with an error.

:::

Key Features​

  • Runs vector similarity search against an Amazon S3 Vectors index.
  • Applies metadata filters on the server side during the vector search, with default filters set at initialization and a filter policy for query-time filters.
  • Returns at most 10,000 documents per query. Search is approximate, so a high top_k can return fewer documents.

Configuration​

Add Workspace-Level Integration​

  1. Click your profile icon and choose Settings.
  2. Go to Workspace>Integrations.
  3. Find the provider you want to connect and click Connect next to them.
  4. Enter the API key and any other required details.
  5. Click Connect. You can use this integration in pipelines and indexes in the current workspace.

Add Organization-Level Integration​

  1. Click your profile icon and choose Settings.
  2. Go to Organization>Integrations.
  3. Find the provider you want to connect and click Connect next to them.
  4. Enter the API key and any other required details.
  5. Click Connect. You can use this integration in pipelines and indexes in all workspaces in the current organization.
  1. Drag the AmazonS3VectorsEmbeddingRetriever component onto the canvas from the Component Library.
  2. Configure an AmazonS3VectorsDocumentStore in your pipeline. Set vector_bucket_name, index_name, and dimension (the embedding size; when you connect to an existing index, its actual dimension is used).
  3. Make sure your AWS credentials can read from the vector bucket. The document store also creates the bucket and index if they don't exist (create_bucket_and_index defaults to True), so it needs create permissions too, or set that parameter to False. Pass credentials with the aws_access_key_id, aws_secret_access_key, and aws_session_token parameters. If you don't set them, the store uses the default AWS credential chain.
  4. Connect an embedder component to provide query_embedding as input. Use the same embedding model that you used to embed the documents in the index.
  5. Connect the retriever output to downstream components such as PromptBuilder.

If the retriever returns no documents or fails, check that your AWS credentials can access the vector bucket and that the query embedding model matches the one used to embed the indexed documents.

Connections​

AmazonS3VectorsEmbeddingRetriever receives a query_embedding (a list of floats) from a text embedder, such as AmazonBedrockTextEmbedder. It outputs a list of Document objects that you can connect to PromptBuilder, a ranker, or other downstream components.

Source Code​

To check this component's source code, open embedding_retriever.py in the Haystack Core Integrations repository.

Usage Examples​

Basic Configuration​

AmazonS3VectorsEmbeddingRetriever:
type: haystack_integrations.components.retrievers.amazon_s3_vectors.embedding_retriever.AmazonS3VectorsEmbeddingRetriever
init_parameters:
document_store:
type: haystack_integrations.document_stores.amazon_s3_vectors.document_store.AmazonS3VectorsDocumentStore
init_parameters:
vector_bucket_name: my-vector-bucket
index_name: my-index
dimension: 1024
top_k: 10

Using the Component in a Pipeline​

This query pipeline embeds the query with an Amazon Bedrock model and sends the embedding to the retriever.

# haystack-pipeline
components:
text_embedder:
type: haystack_integrations.components.embedders.amazon_bedrock.text_embedder.AmazonBedrockTextEmbedder
init_parameters:
model: amazon.titan-embed-text-v2:0
aws_access_key_id:
type: env_var
env_vars:
- AWS_ACCESS_KEY_ID
strict: false
aws_secret_access_key:
type: env_var
env_vars:
- AWS_SECRET_ACCESS_KEY
strict: false
aws_region_name:
type: env_var
env_vars:
- AWS_DEFAULT_REGION
strict: false

retriever:
type: haystack_integrations.components.retrievers.amazon_s3_vectors.embedding_retriever.AmazonS3VectorsEmbeddingRetriever
init_parameters:
document_store:
type: haystack_integrations.document_stores.amazon_s3_vectors.document_store.AmazonS3VectorsDocumentStore
init_parameters:
vector_bucket_name: my-vector-bucket
index_name: my-index
dimension: 1024
distance_metric: cosine
top_k: 10

connections:
- sender: text_embedder.embedding
receiver: retriever.query_embedding

max_runs_per_component: 100

metadata: {}

inputs:
query:
- text_embedder.text

outputs:
documents: retriever.documents

Parameters​

Inputs​

ParameterTypeDescription
query_embeddingList[float]The embedding of the query.
filtersOptional[Dict[str, Any]]Filters to apply to the retrieved documents. The filter_policy determines how they combine with init-time filters.
top_kOptional[int | List[int]]The maximum number of documents to return. S3 Vectors caps this value at 10,000.

Outputs​

ParameterTypeDescription
documentsList[Document]The documents most similar to the query embedding.

Init Parameters​

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
document_storeAmazonS3VectorsDocumentStoreThe S3 Vectors document store to retrieve documents from.
filtersOptional[Dict[str, Any]]NoneDefault filters to apply when retrieving documents.
top_kint10The maximum number of documents to return.
filter_policyFilterPolicyFilterPolicy.REPLACEHow to handle filters passed at query time. REPLACE replaces init-time filters. MERGE combines them.

Run Method Parameters​

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
query_embeddingList[float]The embedding vector to search with.
filtersOptional[Dict[str, Any]]NoneRuntime filters to apply.
top_kOptional[int]NoneThe maximum number of documents to return. Overrides the init-time value.