diff --git a/vector-stores/spring-ai-pgvector-store/src/main/java/org/springframework/ai/pgvector/vectorstore/PgVectorStore.java b/vector-stores/spring-ai-pgvector-store/src/main/java/org/springframework/ai/pgvector/vectorstore/PgVectorStore.java index 968699f50..09c902078 100644 --- a/vector-stores/spring-ai-pgvector-store/src/main/java/org/springframework/ai/pgvector/vectorstore/PgVectorStore.java +++ b/vector-stores/spring-ai-pgvector-store/src/main/java/org/springframework/ai/pgvector/vectorstore/PgVectorStore.java @@ -61,8 +61,97 @@ import org.springframework.util.Assert; import org.springframework.util.StringUtils; /** - * Uses the "vector_store" table to store the Spring AI vector data. The table and the - * vector index will be auto-created if not available. + * PostgreSQL-based vector store implementation using the pgvector extension. + * + *

+ * The store uses a database table to persist the vector embeddings along with their + * associated document content and metadata. By default, it uses the "vector_store" table + * in the "public" schema, but this can be configured. + *

+ * + *

+ * Features: + *

+ * + * + *

+ * Basic usage example: + *

+ *
{@code
+ * PgVectorStore vectorStore = PgVectorStore.builder()
+ *     .jdbcTemplate(jdbcTemplate)
+ *     .embeddingModel(embeddingModel)
+ *     .dimensions(1536) // Optional: defaults to model dimensions or 1536
+ *     .distanceType(PgDistanceType.COSINE_DISTANCE)
+ *     .indexType(PgIndexType.HNSW)
+ *     .build();
+ *
+ * // Add documents
+ * vectorStore.add(List.of(
+ *     new Document("content1", Map.of("key1", "value1")),
+ *     new Document("content2", Map.of("key2", "value2"))
+ * ));
+ *
+ * // Search with filters
+ * List results = vectorStore.similaritySearch(
+ *     SearchRequest.query("search text")
+ *         .withTopK(5)
+ *         .withSimilarityThreshold(0.7)
+ *         .withFilterExpression("key1 == 'value1'")
+ * );
+ * }
+ * + *

+ * Advanced configuration example: + *

+ *
{@code
+ * PgVectorStore vectorStore = PgVectorStore.builder()
+ *     .jdbcTemplate(jdbcTemplate)
+ *     .embeddingModel(embeddingModel)
+ *     .schemaName("custom_schema")
+ *     .vectorTableName("custom_vectors")
+ *     .distanceType(PgDistanceType.NEGATIVE_INNER_PRODUCT)
+ *     .removeExistingVectorStoreTable(true)
+ *     .initializeSchema(true)
+ *     .maxDocumentBatchSize(1000)
+ *     .build();
+ * }
+ * + *

+ * Database Requirements: + *

+ * + * + *

+ * Distance Types: + *

+ * + * + *

+ * Index Types: + *

+ * * * @author Christian Tzolov * @author Josh Long