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_kcan return fewer documents.
Configuration
Add Workspace-Level Integration
- Click your profile icon and choose Settings.
- Go to Workspace>Integrations.
- Find the provider you want to connect and click Connect next to them.
- Enter the API key and any other required details.
- Click Connect. You can use this integration in pipelines and indexes in the current workspace.
Add Organization-Level Integration
- Click your profile icon and choose Settings.
- Go to Organization>Integrations.
- Find the provider you want to connect and click Connect next to them.
- Enter the API key and any other required details.
- Click Connect. You can use this integration in pipelines and indexes in all workspaces in the current organization.
- Drag the
AmazonS3VectorsEmbeddingRetrievercomponent onto the canvas from the Component Library. - Configure an
AmazonS3VectorsDocumentStorein your pipeline. Setvector_bucket_name,index_name, anddimension(the embedding size; when you connect to an existing index, its actual dimension is used). - 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_indexdefaults toTrue), so it needs create permissions too, or set that parameter toFalse. Pass credentials with theaws_access_key_id,aws_secret_access_key, andaws_session_tokenparameters. If you don't set them, the store uses the default AWS credential chain. - Connect an embedder component to provide
query_embeddingas input. Use the same embedding model that you used to embed the documents in the index. - 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
| Parameter | Type | Description |
|---|---|---|
query_embedding | List[float] | The embedding of the query. |
filters | Optional[Dict[str, Any]] | Filters to apply to the retrieved documents. The filter_policy determines how they combine with init-time filters. |
top_k | Optional[int | List[int]] | The maximum number of documents to return. S3 Vectors caps this value at 10,000. |
Outputs
| Parameter | Type | Description |
|---|---|---|
documents | List[Document] | The documents most similar to the query embedding. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
document_store | AmazonS3VectorsDocumentStore | The S3 Vectors document store to retrieve documents from. | |
filters | Optional[Dict[str, Any]] | None | Default filters to apply when retrieving documents. |
top_k | int | 10 | The maximum number of documents to return. |
filter_policy | FilterPolicy | FilterPolicy.REPLACE | How 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
query_embedding | List[float] | The embedding vector to search with. | |
filters | Optional[Dict[str, Any]] | None | Runtime filters to apply. |
top_k | Optional[int] | None | The maximum number of documents to return. Overrides the init-time value. |
Related Information
Was this page helpful?