@@ -93,14 +93,13 @@ private ApplicationContextRunner getContextRunner() {
9393 return new ApplicationContextRunner ().withUserConfiguration (TestApplication .class );
9494 }
9595
96-
9796 @ BeforeEach
9897 void cleanDatabase () {
9998 getContextRunner ().run (context -> {
10099 // deleting indices and data before following tests
101100 ElasticsearchClient elasticsearchClient = context .getBean (ElasticsearchClient .class );
102101 List indices = elasticsearchClient .cat ().indices ().valueBody ().stream ().map (IndicesRecord ::index ).toList ();
103- if (!indices .isEmpty ()) {
102+ if (!indices .isEmpty ()) {
104103 elasticsearchClient .indices ().delete (del -> del .index (indices ));
105104 }
106105 });
@@ -112,7 +111,8 @@ public void addAndSearchTest(String similarityFunction) {
112111
113112 getContextRunner ().run (context -> {
114113
115- ElasticsearchVectorStore vectorStore = context .getBean ("vectorStore_" +similarityFunction , ElasticsearchVectorStore .class );
114+ ElasticsearchVectorStore vectorStore = context .getBean ("vectorStore_" + similarityFunction ,
115+ ElasticsearchVectorStore .class );
116116
117117 vectorStore .add (documents );
118118
@@ -147,7 +147,8 @@ public void addAndSearchTest(String similarityFunction) {
147147 public void searchWithFilters (String similarityFunction ) {
148148
149149 getContextRunner ().run (context -> {
150- ElasticsearchVectorStore vectorStore = context .getBean ("vectorStore_" +similarityFunction , ElasticsearchVectorStore .class );
150+ ElasticsearchVectorStore vectorStore = context .getBean ("vectorStore_" + similarityFunction ,
151+ ElasticsearchVectorStore .class );
151152
152153 var bgDocument = new Document ("1" , "The World is Big and Salvation Lurks Around the Corner" ,
153154 Map .of ("country" , "BG" , "year" , 2020 , "activationDate" , new Date (1000 )));
@@ -243,7 +244,8 @@ public void searchWithFilters(String similarityFunction) {
243244 public void documentUpdateTest (String similarityFunction ) {
244245
245246 getContextRunner ().run (context -> {
246- ElasticsearchVectorStore vectorStore = context .getBean ("vectorStore_" +similarityFunction , ElasticsearchVectorStore .class );
247+ ElasticsearchVectorStore vectorStore = context .getBean ("vectorStore_" + similarityFunction ,
248+ ElasticsearchVectorStore .class );
247249
248250 Document document = new Document (UUID .randomUUID ().toString (), "Spring AI rocks!!" ,
249251 Map .of ("meta1" , "meta1" ));
@@ -295,7 +297,8 @@ public void documentUpdateTest(String similarityFunction) {
295297 @ ValueSource (strings = { "cosine" , "l2_norm" , "dot_product" })
296298 public void searchThresholdTest (String similarityFunction ) {
297299 getContextRunner ().run (context -> {
298- ElasticsearchVectorStore vectorStore = context .getBean ("vectorStore_" +similarityFunction , ElasticsearchVectorStore .class );
300+ ElasticsearchVectorStore vectorStore = context .getBean ("vectorStore_" + similarityFunction ,
301+ ElasticsearchVectorStore .class );
299302
300303 vectorStore .add (documents );
301304
@@ -344,15 +347,15 @@ public ElasticsearchVectorStore vectorStoreL2(EmbeddingClient embeddingClient, R
344347 ElasticsearchVectorStoreOptions options = new ElasticsearchVectorStoreOptions ();
345348 options .setIndexName ("index_l2" );
346349 options .setSimilarity (SimilarityFunction .l2_norm );
347- return new ElasticsearchVectorStore (options ,restClient , embeddingClient );
350+ return new ElasticsearchVectorStore (options , restClient , embeddingClient );
348351 }
349352
350353 @ Bean ("vectorStore_dot_product" )
351354 public ElasticsearchVectorStore vectorStoreDotProduct (EmbeddingClient embeddingClient , RestClient restClient ) {
352355 ElasticsearchVectorStoreOptions options = new ElasticsearchVectorStoreOptions ();
353356 options .setIndexName ("index_dot_product" );
354357 options .setSimilarity (SimilarityFunction .dot_product );
355- return new ElasticsearchVectorStore (options ,restClient , embeddingClient );
358+ return new ElasticsearchVectorStore (options , restClient , embeddingClient );
356359 }
357360
358361 @ Bean
@@ -372,4 +375,5 @@ ElasticsearchClient elasticsearchClient(RestClient restClient) {
372375 }
373376
374377 }
378+
375379}
0 commit comments