examples/google-alloydb-vectorstore-example/README.md
This example demonstrates how to use AlloyDB for Postgres for vector similarity search with LangChain in Go.
Creates a AlloyDB VectorStore:
alloydb.PostgresEngine object to establish a connection to the AlloyDB database.alloydb.VectorStore object using a VertexAI model for embeddings.Initializes VertexAI Embeddings:
Adds Sample Documents:
Performs Similarity Searches:
Set the following environment variables. Your AlloyDB values can be found in the Google Cloud Console:
export PROJECT_ID=<your project Id>
export GOOGLE_CLOUD_LOCATION=<your cloud location>
export ALLOYDB_USERNAME=<your user>
export ALLOYDB_PASSWORD=<your password>
export ALLOYDB_REGION=<your region>
export ALLOYDB_CLUSTER=<your cluster>
export ALLOYDB_INSTANCE=<your instance>
export ALLOYDB_DATABASE=<your database>
export ALLOYDB_TABLE=<your tablename>
Run the Go example:
go run google_alloydb_vectorstore_example.go
alloydb.PostgresEngine for connection pooling.alloydb.VectorStore.This example provides a practical demonstration of using vector databases for semantic search and similarity matching, which can be incredibly useful for various AI and machine learning applications.