AstraDocumentStore
Store and retrieve documents using DataStax Astra DB, a serverless vector database built on Apache Cassandra.
Key Features
- Stores documents in Astra DB with native vector search support.
- Serverless architecture that scales automatically with usage.
- Supports cosine, dot product, and Euclidean similarity functions.
- Supports namespace isolation for multi-tenant use cases.
- Configurable duplicate handling policies.
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.
- Create an Astra DB instance and obtain your API endpoint and application token from the Astra DB console.
- Create secrets with your Astra credentials. For instructions, see Create Secrets:
ASTRA_DB_API_ENDPOINT: Your Astra DB API endpoint.ASTRA_DB_APPLICATION_TOKEN: Your Astra DB application token.
- Configure the
AstraDocumentStorein your pipeline YAML.
Source Code
To check this component's source code, open document_store.py in the Haystack Core Integrations repository.
Usage Examples
Basic Configuration
AstraDocumentStore:
type: haystack_integrations.document_stores.astra.document_store.AstraDocumentStore
init_parameters:
api_endpoint:
type: env_var
env_vars:
- ASTRA_DB_API_ENDPOINT
strict: true
token:
type: env_var
env_vars:
- ASTRA_DB_APPLICATION_TOKEN
strict: true
collection_name: haystack_docs
embedding_dimension: 768
similarity: cosine
Parameters
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
api_endpoint | Secret | Secret.from_env_var("ASTRA_DB_API_ENDPOINT") | The Astra DB API endpoint URL. |
token | Secret | Secret.from_env_var("ASTRA_DB_APPLICATION_TOKEN") | The Astra DB application token. |
collection_name | str | documents | The name of the Astra DB collection to store documents in. |
embedding_dimension | int | 768 | The dimensionality of document embeddings. Must match your embedding model's output. |
duplicates_policy | DuplicatePolicy | DuplicatePolicy.NONE | How to handle duplicate documents. One of NONE, SKIP, OVERWRITE, or FAIL. |
similarity | str | cosine | The vector similarity metric. One of cosine, dot_product, or euclidean. |
namespace | Optional[str] | None | The Astra DB namespace (keyspace) to use. |
Related Information
Was this page helpful?