2121import io .weaviate .ConcurrentTest ;
2222import io .weaviate .client6 .v1 .api .WeaviateApiException ;
2323import io .weaviate .client6 .v1 .api .WeaviateClient ;
24+ import io .weaviate .client6 .v1 .api .collections .Generative ;
2425import io .weaviate .client6 .v1 .api .collections .ObjectMetadata ;
2526import io .weaviate .client6 .v1 .api .collections .Property ;
2627import io .weaviate .client6 .v1 .api .collections .ReferenceProperty ;
28+ import io .weaviate .client6 .v1 .api .collections .Reranker ;
2729import io .weaviate .client6 .v1 .api .collections .VectorConfig ;
2830import io .weaviate .client6 .v1 .api .collections .Vectors ;
2931import io .weaviate .client6 .v1 .api .collections .WeaviateMetadata ;
3739import io .weaviate .client6 .v1 .api .collections .query .Metadata ;
3840import io .weaviate .client6 .v1 .api .collections .query .QueryMetadata ;
3941import io .weaviate .client6 .v1 .api .collections .query .QueryResponseGroup ;
42+ import io .weaviate .client6 .v1 .api .collections .query .Rerank ;
4043import io .weaviate .client6 .v1 .api .collections .query .SortBy ;
4144import io .weaviate .client6 .v1 .api .collections .query .Target ;
45+ import io .weaviate .client6 .v1 .api .collections .rerankers .DummyReranker ;
4246import io .weaviate .client6 .v1 .api .collections .vectorindex .Hnsw ;
4347import io .weaviate .client6 .v1 .api .collections .vectorindex .MultiVector ;
4448import io .weaviate .containers .Container ;
@@ -52,7 +56,7 @@ public class SearchITest extends ConcurrentTest {
5256 Weaviate .custom ()
5357 .withModel2VecUrl (Model2Vec .URL )
5458 .withImageInference (Img2VecNeural .URL , Img2VecNeural .MODULE )
55- .addModules ("generative-dummy" )
59+ .addModules (Generative . Kind . DUMMY . jsonValue (), Reranker . Kind . DUMMY . jsonValue () )
5660 .build (),
5761 Container .IMG2VEC_NEURAL ,
5862 Container .MODEL2VEC );
@@ -741,7 +745,7 @@ public void teset_filterPropertyLength() throws IOException {
741745 // Assertions
742746 Assertions .assertThat (got .objects ()).hasSize (2 );
743747 }
744-
748+
745749 /**
746750 * Ensure the client respects server's configuration for max gRPC size:
747751 * we create a server with 1-byte message size and try to send a large payload
@@ -768,4 +772,30 @@ public void test_maxGrpcMessageSize() throws Exception {
768772 }).isInstanceOf (io .grpc .StatusRuntimeException .class );
769773 }
770774 }
775+
776+ @ Test
777+ public void test_rerankQueries () throws IOException {
778+ // Arrange
779+ var nsThigns = ns ("Things" );
780+
781+ var things = client .collections .create (nsThigns ,
782+ c -> c
783+ .properties (Property .text ("title" ), Property .integer ("price" ))
784+ .vectorConfig (VectorConfig .text2vecModel2Vec (
785+ t2v -> t2v .sourceProperties ("title" , "price" )))
786+ .rerankerModules (new DummyReranker ()));
787+
788+ things .data .insertMany (
789+ Map .of ("title" , "Ergonomic chair" , "price" , 269 ),
790+ Map .of ("title" , "Height-adjustable desk" , "price" , 349 ));
791+
792+ // Act
793+ var got = things .query .nearText (
794+ "office supplies" ,
795+ nt -> nt .rerank (Rerank .by ("price" ,
796+ rank -> rank .query ("cheaper first" ))));
797+
798+ // Assert: ranking not important really, just that the request was valid.
799+ Assertions .assertThat (got .objects ()).hasSize (2 );
800+ }
771801}
0 commit comments