Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
l-trotta committed Sep 10, 2024
1 parent 692ed87 commit 48722da
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,33 @@ void cleanDatabase() {
}

@Test
public void addAndDeleteDocumentsTest(){
public void addAndDeleteDocumentsTest() {
getContextRunner().run(context -> {
ElasticsearchVectorStore vectorStore = context.getBean("vectorStore_cosine",
ElasticsearchVectorStore.class);
ElasticsearchClient elasticsearchClient = context.getBean(ElasticsearchClient.class);

IndicesStats stats = elasticsearchClient.indices().stats(s -> s.index("spring-ai-document-index")).indices().get("spring-ai-document-index");
IndicesStats stats = elasticsearchClient.indices()
.stats(s -> s.index("spring-ai-document-index"))
.indices()
.get("spring-ai-document-index");

assertThat(stats.total().docs().count()).isEqualTo(0L);

vectorStore.add(documents);
elasticsearchClient.indices().refresh();
stats = elasticsearchClient.indices().stats(s -> s.index("spring-ai-document-index")).indices().get("spring-ai-document-index");
stats = elasticsearchClient.indices()
.stats(s -> s.index("spring-ai-document-index"))
.indices()
.get("spring-ai-document-index");
assertThat(stats.total().docs().count()).isEqualTo(3L);

vectorStore.doDelete(List.of("1", "2", "3"));
elasticsearchClient.indices().refresh();
stats = elasticsearchClient.indices().stats(s -> s.index("spring-ai-document-index")).indices().get("spring-ai-document-index");
stats = elasticsearchClient.indices()
.stats(s -> s.index("spring-ai-document-index"))
.indices()
.get("spring-ai-document-index");
assertThat(stats.total().docs().count()).isEqualTo(0L);
});
}
Expand Down

0 comments on commit 48722da

Please sign in to comment.