@@ -174,7 +174,10 @@ public void testRRFPagination() {
174174 );
175175 // this one retrieves docs 2 and 6 due to prefilter
176176 StandardRetrieverBuilder standard1 = new StandardRetrieverBuilder (
177- QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" , "doc_3" , "doc_6" )).boost (20L )
177+ QueryBuilders .boolQuery ()
178+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" )).boost (20L ))
179+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_3" )).boost (10L ))
180+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_6" )).boost (5L ))
178181 );
179182 standard1 .getPreFilterQueryBuilders ().add (QueryBuilders .queryStringQuery ("search" ).defaultField (TEXT_FIELD ));
180183 // this one retrieves docs 2, 3, 6, and 7
@@ -221,7 +224,10 @@ public void testRRFWithAggs() {
221224 );
222225 // this one retrieves docs 2 and 6 due to prefilter
223226 StandardRetrieverBuilder standard1 = new StandardRetrieverBuilder (
224- QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" , "doc_3" , "doc_6" )).boost (20L )
227+ QueryBuilders .boolQuery ()
228+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" )).boost (20L ))
229+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_3" )).boost (10L ))
230+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_6" )).boost (5L ))
225231 );
226232 standard1 .getPreFilterQueryBuilders ().add (QueryBuilders .queryStringQuery ("search" ).defaultField (TEXT_FIELD ));
227233 // this one retrieves docs 2, 3, 6, and 7
@@ -273,7 +279,10 @@ public void testRRFWithCollapse() {
273279 );
274280 // this one retrieves docs 2 and 6 due to prefilter
275281 StandardRetrieverBuilder standard1 = new StandardRetrieverBuilder (
276- QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" , "doc_3" , "doc_6" )).boost (20L )
282+ QueryBuilders .boolQuery ()
283+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" )).boost (20L ))
284+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_3" )).boost (10L ))
285+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_6" )).boost (5L ))
277286 );
278287 standard1 .getPreFilterQueryBuilders ().add (QueryBuilders .queryStringQuery ("search" ).defaultField (TEXT_FIELD ));
279288 // this one retrieves docs 2, 3, 6, and 7
@@ -327,7 +336,10 @@ public void testRRFRetrieverWithCollapseAndAggs() {
327336 );
328337 // this one retrieves docs 2 and 6 due to prefilter
329338 StandardRetrieverBuilder standard1 = new StandardRetrieverBuilder (
330- QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" , "doc_3" , "doc_6" )).boost (20L )
339+ QueryBuilders .boolQuery ()
340+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" )).boost (20L ))
341+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_3" )).boost (10L ))
342+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_6" )).boost (5L ))
331343 );
332344 standard1 .getPreFilterQueryBuilders ().add (QueryBuilders .queryStringQuery ("search" ).defaultField (TEXT_FIELD ));
333345 // this one retrieves docs 2, 3, 6, and 7
@@ -390,7 +402,10 @@ public void testMultipleRRFRetrievers() {
390402 );
391403 // this one retrieves docs 2 and 6 due to prefilter
392404 StandardRetrieverBuilder standard1 = new StandardRetrieverBuilder (
393- QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" , "doc_3" , "doc_6" )).boost (20L )
405+ QueryBuilders .boolQuery ()
406+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" )).boost (20L ))
407+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_3" )).boost (10L ))
408+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_6" )).boost (5L ))
394409 );
395410 standard1 .getPreFilterQueryBuilders ().add (QueryBuilders .queryStringQuery ("search" ).defaultField (TEXT_FIELD ));
396411 // this one retrieves docs 2, 3, 6, and 7
@@ -453,7 +468,10 @@ public void testRRFExplainWithNamedRetrievers() {
453468 standard0 .retrieverName ("my_custom_retriever" );
454469 // this one retrieves docs 2 and 6 due to prefilter
455470 StandardRetrieverBuilder standard1 = new StandardRetrieverBuilder (
456- QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" , "doc_3" , "doc_6" )).boost (20L )
471+ QueryBuilders .boolQuery ()
472+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" )).boost (20L ))
473+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_3" )).boost (10L ))
474+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_6" )).boost (5L ))
457475 );
458476 standard1 .getPreFilterQueryBuilders ().add (QueryBuilders .queryStringQuery ("search" ).defaultField (TEXT_FIELD ));
459477 // this one retrieves docs 2, 3, 6, and 7
@@ -509,7 +527,10 @@ public void testRRFExplainWithAnotherNestedRRF() {
509527 standard0 .retrieverName ("my_custom_retriever" );
510528 // this one retrieves docs 2 and 6 due to prefilter
511529 StandardRetrieverBuilder standard1 = new StandardRetrieverBuilder (
512- QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" , "doc_3" , "doc_6" )).boost (20L )
530+ QueryBuilders .boolQuery ()
531+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" )).boost (20L ))
532+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_3" )).boost (10L ))
533+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_6" )).boost (5L ))
513534 );
514535 standard1 .getPreFilterQueryBuilders ().add (QueryBuilders .queryStringQuery ("search" ).defaultField (TEXT_FIELD ));
515536 // this one retrieves docs 2, 3, 6, and 7
@@ -577,7 +598,10 @@ public void testRRFInnerRetrieverSearchError() {
577598 QueryBuilders .constantScoreQuery (QueryBuilders .rangeQuery (VECTOR_FIELD ).gte (10 ))
578599 );
579600 StandardRetrieverBuilder standard1 = new StandardRetrieverBuilder (
580- QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" , "doc_3" , "doc_6" )).boost (20L )
601+ QueryBuilders .boolQuery ()
602+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" )).boost (20L ))
603+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_3" )).boost (10L ))
604+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_6" )).boost (5L ))
581605 );
582606 standard1 .getPreFilterQueryBuilders ().add (QueryBuilders .queryStringQuery ("search" ).defaultField (TEXT_FIELD ));
583607 source .retriever (
@@ -613,7 +637,10 @@ public void extractToSearchSourceBuilder(SearchSourceBuilder searchSourceBuilder
613637 }
614638 };
615639 StandardRetrieverBuilder standard1 = new StandardRetrieverBuilder (
616- QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" , "doc_3" , "doc_6" )).boost (20L )
640+ QueryBuilders .boolQuery ()
641+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" )).boost (20L ))
642+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_3" )).boost (10L ))
643+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_6" )).boost (5L ))
617644 );
618645 standard1 .getPreFilterQueryBuilders ().add (QueryBuilders .queryStringQuery ("search" ).defaultField (TEXT_FIELD ));
619646 source .retriever (
@@ -646,7 +673,10 @@ public void extractToSearchSourceBuilder(SearchSourceBuilder searchSourceBuilder
646673 }
647674 };
648675 StandardRetrieverBuilder standard1 = new StandardRetrieverBuilder (
649- QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" , "doc_3" , "doc_6" )).boost (20L )
676+ QueryBuilders .boolQuery ()
677+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_2" )).boost (20L ))
678+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_3" )).boost (10L ))
679+ .should (QueryBuilders .constantScoreQuery (QueryBuilders .idsQuery ().addIds ("doc_6" )).boost (5L ))
650680 );
651681 standard1 .getPreFilterQueryBuilders ().add (QueryBuilders .queryStringQuery ("search" ).defaultField (TEXT_FIELD ));
652682 source .retriever (
0 commit comments