This version is still in development and is not considered stable yet. For the latest snapshot version, please use Spring AI 1.0.0-SNAPSHOT! |
You can run a PGvector database as a Spring Boot dev service via Docker Compose or Testcontainers. In alternative, the setup local Postgres/PGVector appendix shows how to set up a DB locally with a Docker container. |
replace the 1536 with the actual embedding dimension if you are using a different dimension. PGvector supports at most 2000 dimensions for HNSW indexes.
|
This is a breaking change! In earlier versions of Spring AI, this schema initialization happened by default. |
Refer to the Dependency Management section to add the Spring AI BOM to your build file. Refer to the Repositories section to add Milestone and/or Snapshot Repositories to your build file. |
If you run PGvector as a Spring Boot dev service via Docker Compose or Testcontainers, you don’t need to configure URL, username and password since they are autoconfigured by Spring Boot. |
Check the list of configuration parameters to learn about the default values and configuration options. |
Property | Description | Default value |
---|---|---|
|
Nearest neighbor search index type. Options are |
HNSW |
|
Search distance type. Defaults to |
COSINE_DISTANCE |
|
Embeddings dimension. If not specified explicitly the PgVectorStore will retrieve the dimensions form the provided |
- |
|
Deletes the existing |
false |
|
Whether to initialize the required schema |
false |
|
Vector store schema name |
|
|
Vector store table name |
|
|
Enables schema and table name validation to ensure they are valid and existing objects. |
false |
If you configure a custom schema and/or table name, consider enabling schema validation by setting spring.ai.vectorstore.pgvector.schema-validation=true .
This ensures the correctness of the names and reduces the risk of SQL injection attacks.
|
These filter expressions are converted into the equivalent PgVector filters. |
Refer to the Dependency Management section to add the Spring AI BOM to your build file. |