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

AlloyDBDocumentStore

Store and retrieve documents using AlloyDB for PostgreSQL, Google Cloud's fully managed, PostgreSQL-compatible database with built-in vector search capabilities.

Key Features

  • Stores documents in AlloyDB with full-text and vector search support.
  • Supports exact nearest neighbor (ENN) and HNSW approximate nearest neighbor (ANN) vector search strategies.
  • Supports multiple vector similarity functions: cosine similarity, inner product, and L2 distance.
  • Supports IAM authentication for secure, keyless access.
  • Configurable connection via public, private, or PSC IP types.

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. Set up the AlloyDB instance and create a database.
  2. Set the ALLOYDB_INSTANCE_URI, ALLOYDB_USER, and ALLOYDB_PASSWORD environment variables. For instructions, see Create Secrets.
  3. Configure the AlloyDBDocumentStore in your pipeline YAML with the appropriate connection parameters and embedding dimension.

Source Code

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

Usage Examples

Basic Configuration

  AlloyDBDocumentStore:
type: haystack_integrations.document_stores.alloydb.document_store.AlloyDBDocumentStore
init_parameters:
instance_uri:
type: env_var
env_vars:
- ALLOYDB_INSTANCE_URI
strict: true
user:
type: env_var
env_vars:
- ALLOYDB_USER
strict: true
password:
type: env_var
env_vars:
- ALLOYDB_PASSWORD
strict: false
db: my_database
embedding_dimension: 768
  AlloyDBDocumentStore:
type: haystack_integrations.document_stores.alloydb.document_store.AlloyDBDocumentStore
init_parameters:
instance_uri:
type: env_var
env_vars:
- ALLOYDB_INSTANCE_URI
strict: true
user:
type: env_var
env_vars:
- ALLOYDB_USER
strict: true
password:
type: env_var
env_vars:
- ALLOYDB_PASSWORD
strict: false
db: my_database
embedding_dimension: 768
search_strategy: hnsw
vector_function: cosine_similarity

Parameters

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
instance_uriSecretSecret.from_env_var("ALLOYDB_INSTANCE_URI")The AlloyDB instance URI.
userSecretSecret.from_env_var("ALLOYDB_USER")The database user.
passwordSecretSecret.from_env_var("ALLOYDB_PASSWORD", strict=False)The database password. Not required when using IAM authentication.
dbstrpostgresThe name of the database to connect to.
enable_iam_authboolFalseWhether to use IAM authentication.
ip_typestrPRIVATEThe IP type for the connection. One of PRIVATE, PUBLIC, or PSC.
create_extensionboolTrueWhether to create the vector extension if it doesn't exist.
schema_namestrpublicThe schema name where the document table is stored.
table_namestrhaystack_documentsThe name of the table to store documents in.
languagestrenglishThe language used for full-text search indexing.
embedding_dimensionint768The dimensionality of document embeddings. Must match your embedding model's output.
vector_functionstrcosine_similarityThe vector similarity function. One of cosine_similarity, inner_product, or l2_distance.
recreate_tableboolFalseWhether to drop and recreate the document table on initialization.
search_strategystrexact_nearest_neighborThe vector search strategy. One of exact_nearest_neighbor or hnsw.
hnsw_recreate_index_if_existsboolFalseWhether to recreate the HNSW index if it already exists.
hnsw_index_creation_kwargsOptional[Dict[str, int]]NoneAdditional keyword arguments for HNSW index creation (for example, m and ef_construction).
hnsw_index_namestrhaystack_hnsw_indexThe name of the HNSW index.
hnsw_ef_searchOptional[int]NoneThe ef_search parameter for HNSW queries. Higher values improve recall at the cost of speed.
keyword_index_namestrhaystack_keyword_indexThe name of the full-text search index.