@@ -132,13 +132,12 @@ public void addAndSearchTest(String similarityFunction) {
132
132
vectorStore .add (documents );
133
133
134
134
Awaitility .await ()
135
- .until (() -> vectorStore . similaritySearch ( SearchRequest . query ( "Great Depression" )
136
- .withTopK (1 )
137
- . withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )), hasSize (1 ));
135
+ .until (() -> vectorStore
136
+ .similaritySearch ( SearchRequest . query ( "Great Depression" ). withTopK (1 ). withSimilarityThresholdAll ()),
137
+ hasSize (1 ));
138
138
139
- List <Document > results = vectorStore .similaritySearch (SearchRequest .query ("Great Depression" )
140
- .withTopK (1 )
141
- .withSimilarityThreshold (SearchRequest .SIMILARITY_THRESHOLD_ACCEPT_ALL ));
139
+ List <Document > results = vectorStore
140
+ .similaritySearch (SearchRequest .query ("Great Depression" ).withTopK (1 ).withSimilarityThresholdAll ());
142
141
143
142
assertThat (results ).hasSize (1 );
144
143
Document resultDoc = results .get (0 );
@@ -152,9 +151,9 @@ public void addAndSearchTest(String similarityFunction) {
152
151
vectorStore .delete (documents .stream ().map (Document ::getId ).toList ());
153
152
154
153
Awaitility .await ()
155
- .until (() -> vectorStore . similaritySearch ( SearchRequest . query ( "Great Depression" )
156
- .withTopK (1 )
157
- . withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )), hasSize (0 ));
154
+ .until (() -> vectorStore
155
+ .similaritySearch ( SearchRequest . query ( "Great Depression" ). withTopK (1 ). withSimilarityThresholdAll ()),
156
+ hasSize (0 ));
158
157
});
159
158
}
160
159
@@ -177,21 +176,21 @@ public void searchWithFilters(String similarityFunction) {
177
176
vectorStore .add (List .of (bgDocument , nlDocument , bgDocument2 ));
178
177
179
178
Awaitility .await ()
180
- .until (() -> vectorStore . similaritySearch ( SearchRequest . query ( "The World" )
181
- .withTopK (5 )
182
- . withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )), hasSize (3 ));
179
+ .until (() -> vectorStore
180
+ .similaritySearch ( SearchRequest . query ( "The World" ). withTopK (5 ). withSimilarityThresholdAll ()),
181
+ hasSize (3 ));
183
182
184
183
List <Document > results = vectorStore .similaritySearch (SearchRequest .query ("The World" )
185
184
.withTopK (5 )
186
- .withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )
185
+ .withSimilarityThresholdAll ( )
187
186
.withFilterExpression ("country == 'NL'" ));
188
187
189
188
assertThat (results ).hasSize (1 );
190
189
assertThat (results .get (0 ).getId ()).isEqualTo (nlDocument .getId ());
191
190
192
191
results = vectorStore .similaritySearch (SearchRequest .query ("The World" )
193
192
.withTopK (5 )
194
- .withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )
193
+ .withSimilarityThresholdAll ( )
195
194
.withFilterExpression ("country == 'BG'" ));
196
195
197
196
assertThat (results ).hasSize (2 );
@@ -200,15 +199,15 @@ public void searchWithFilters(String similarityFunction) {
200
199
201
200
results = vectorStore .similaritySearch (SearchRequest .query ("The World" )
202
201
.withTopK (5 )
203
- .withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )
202
+ .withSimilarityThresholdAll ( )
204
203
.withFilterExpression ("country == 'BG' && year == 2020" ));
205
204
206
205
assertThat (results ).hasSize (1 );
207
206
assertThat (results .get (0 ).getId ()).isEqualTo (bgDocument .getId ());
208
207
209
208
results = vectorStore .similaritySearch (SearchRequest .query ("The World" )
210
209
.withTopK (5 )
211
- .withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )
210
+ .withSimilarityThresholdAll ( )
212
211
.withFilterExpression ("country in ['BG']" ));
213
212
214
213
assertThat (results ).hasSize (2 );
@@ -217,22 +216,22 @@ public void searchWithFilters(String similarityFunction) {
217
216
218
217
results = vectorStore .similaritySearch (SearchRequest .query ("The World" )
219
218
.withTopK (5 )
220
- .withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )
219
+ .withSimilarityThresholdAll ( )
221
220
.withFilterExpression ("country in ['BG','NL']" ));
222
221
223
222
assertThat (results ).hasSize (3 );
224
223
225
224
results = vectorStore .similaritySearch (SearchRequest .query ("The World" )
226
225
.withTopK (5 )
227
- .withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )
226
+ .withSimilarityThresholdAll ( )
228
227
.withFilterExpression ("country not in ['BG']" ));
229
228
230
229
assertThat (results ).hasSize (1 );
231
230
assertThat (results .get (0 ).getId ()).isEqualTo (nlDocument .getId ());
232
231
233
232
results = vectorStore .similaritySearch (SearchRequest .query ("The World" )
234
233
.withTopK (5 )
235
- .withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )
234
+ .withSimilarityThresholdAll ( )
236
235
.withFilterExpression ("NOT(country not in ['BG'])" ));
237
236
238
237
assertThat (results ).hasSize (2 );
@@ -241,7 +240,7 @@ public void searchWithFilters(String similarityFunction) {
241
240
242
241
results = vectorStore .similaritySearch (SearchRequest .query ("The World" )
243
242
.withTopK (5 )
244
- .withSimilarityThreshold ( SearchRequest . SIMILARITY_THRESHOLD_ACCEPT_ALL )
243
+ .withSimilarityThresholdAll ( )
245
244
.withFilterExpression (
246
245
"activationDate > " + ZonedDateTime .parse ("1970-01-01T00:00:02Z" ).toInstant ().toEpochMilli ()));
247
246
@@ -270,13 +269,12 @@ public void documentUpdateTest(String similarityFunction) {
270
269
vectorStore .add (List .of (document ));
271
270
272
271
Awaitility .await ()
273
- .until (() -> vectorStore . similaritySearch ( SearchRequest . query ( "Spring" )
274
- .withSimilarityThreshold (SearchRequest .SIMILARITY_THRESHOLD_ACCEPT_ALL )
275
- . withTopK ( 5 )), hasSize (1 ));
272
+ .until (() -> vectorStore
273
+ .similaritySearch (SearchRequest .query ( "Spring" ). withSimilarityThresholdAll (). withTopK ( 5 )),
274
+ hasSize (1 ));
276
275
277
- List <Document > results = vectorStore .similaritySearch (SearchRequest .query ("Spring" )
278
- .withSimilarityThreshold (SearchRequest .SIMILARITY_THRESHOLD_ACCEPT_ALL )
279
- .withTopK (5 ));
276
+ List <Document > results = vectorStore
277
+ .similaritySearch (SearchRequest .query ("Spring" ).withSimilarityThresholdAll ().withTopK (5 ));
280
278
281
279
assertThat (results ).hasSize (1 );
282
280
Document resultDoc = results .get (0 );
@@ -289,9 +287,7 @@ public void documentUpdateTest(String similarityFunction) {
289
287
"The World is Big and Salvation Lurks Around the Corner" , Map .of ("meta2" , "meta2" ));
290
288
291
289
vectorStore .add (List .of (sameIdDocument ));
292
- SearchRequest fooBarSearchRequest = SearchRequest .query ("FooBar" )
293
- .withTopK (5 )
294
- .withSimilarityThreshold (SearchRequest .SIMILARITY_THRESHOLD_ACCEPT_ALL );
290
+ SearchRequest fooBarSearchRequest = SearchRequest .query ("FooBar" ).withTopK (5 ).withSimilarityThresholdAll ();
295
291
296
292
Awaitility .await ()
297
293
.until (() -> vectorStore .similaritySearch (fooBarSearchRequest ).get (0 ).getContent (),
@@ -324,9 +320,7 @@ public void searchThresholdTest(String similarityFunction) {
324
320
325
321
vectorStore .add (documents );
326
322
327
- SearchRequest query = SearchRequest .query ("Great Depression" )
328
- .withTopK (50 )
329
- .withSimilarityThreshold (SearchRequest .SIMILARITY_THRESHOLD_ACCEPT_ALL );
323
+ SearchRequest query = SearchRequest .query ("Great Depression" ).withTopK (50 ).withSimilarityThresholdAll ();
330
324
331
325
Awaitility .await ().until (() -> vectorStore .similaritySearch (query ), hasSize (3 ));
332
326
@@ -352,9 +346,8 @@ public void searchThresholdTest(String similarityFunction) {
352
346
vectorStore .delete (documents .stream ().map (Document ::getId ).toList ());
353
347
354
348
Awaitility .await ()
355
- .until (() -> vectorStore .similaritySearch (SearchRequest .query ("Great Depression" )
356
- .withTopK (50 )
357
- .withSimilarityThreshold (SearchRequest .SIMILARITY_THRESHOLD_ACCEPT_ALL )), hasSize (0 ));
349
+ .until (() -> vectorStore .similaritySearch (
350
+ SearchRequest .query ("Great Depression" ).withTopK (50 ).withSimilarityThresholdAll ()), hasSize (0 ));
358
351
});
359
352
}
360
353
0 commit comments