|
75 | 75 | * @author Christian Tzolov
|
76 | 76 | * @author Thomas Vitale
|
77 | 77 | * @author Jihoon Kim
|
| 78 | + * @author YeongMin Song |
78 | 79 | */
|
79 | 80 | @Testcontainers
|
80 | 81 | @EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+")
|
@@ -232,6 +233,47 @@ public void testToPgTypeWithNonUuidIdType() {
|
232 | 233 | });
|
233 | 234 | }
|
234 | 235 |
|
| 236 | + @Test |
| 237 | + public void testBulkOperationWithUuidIdType() { |
| 238 | + this.contextRunner.withPropertyValues("test.spring.ai.vectorstore.pgvector.distanceType=" + "COSINE_DISTANCE") |
| 239 | + .run(context -> { |
| 240 | + |
| 241 | + VectorStore vectorStore = context.getBean(VectorStore.class); |
| 242 | + |
| 243 | + List<Document> documents = List.of( |
| 244 | + new Document(new RandomIdGenerator().generateId(), "TEXT", new HashMap<>()), |
| 245 | + new Document(new RandomIdGenerator().generateId(), "TEXT", new HashMap<>()), |
| 246 | + new Document(new RandomIdGenerator().generateId(), "TEXT", new HashMap<>())); |
| 247 | + vectorStore.add(documents); |
| 248 | + |
| 249 | + List<String> idList = documents.stream().map(Document::getId).toList(); |
| 250 | + vectorStore.delete(idList); |
| 251 | + |
| 252 | + dropTable(context); |
| 253 | + }); |
| 254 | + } |
| 255 | + |
| 256 | + @Test |
| 257 | + public void testBulkOperationWithNonUuidIdType() { |
| 258 | + this.contextRunner.withPropertyValues("test.spring.ai.vectorstore.pgvector.distanceType=" + "COSINE_DISTANCE") |
| 259 | + .withPropertyValues("test.spring.ai.vectorstore.pgvector.initializeSchema=" + false) |
| 260 | + .withPropertyValues("test.spring.ai.vectorstore.pgvector.idType=" + "TEXT") |
| 261 | + .run(context -> { |
| 262 | + VectorStore vectorStore = context.getBean(VectorStore.class); |
| 263 | + initSchema(context); |
| 264 | + |
| 265 | + List<Document> documents = List.of(new Document("NON_UUID_1", "TEXT", new HashMap<>()), |
| 266 | + new Document("NON_UUID_2", "TEXT", new HashMap<>()), |
| 267 | + new Document("NON_UUID_3", "TEXT", new HashMap<>())); |
| 268 | + vectorStore.add(documents); |
| 269 | + |
| 270 | + List<String> idList = documents.stream().map(Document::getId).toList(); |
| 271 | + vectorStore.delete(idList); |
| 272 | + |
| 273 | + dropTable(context); |
| 274 | + }); |
| 275 | + } |
| 276 | + |
235 | 277 | @ParameterizedTest(name = "Filter expression {0} should return {1} records ")
|
236 | 278 | @MethodSource("provideFilters")
|
237 | 279 | public void searchWithInFilter(String expression, Integer expectedRecords) {
|
@@ -436,6 +478,8 @@ void getNativeClientTest() {
|
436 | 478 | PgVectorStore vectorStore = context.getBean(PgVectorStore.class);
|
437 | 479 | Optional<JdbcTemplate> nativeClient = vectorStore.getNativeClient();
|
438 | 480 | assertThat(nativeClient).isPresent();
|
| 481 | + |
| 482 | + dropTable(context); |
439 | 483 | });
|
440 | 484 | }
|
441 | 485 |
|
|
0 commit comments