|
36 | 36 | import io.weaviate.client6.v1.api.collections.query.Filter; |
37 | 37 | import io.weaviate.client6.v1.api.collections.query.GroupBy; |
38 | 38 | import io.weaviate.client6.v1.api.collections.query.Metadata; |
| 39 | +import io.weaviate.client6.v1.api.collections.query.QueryProfile; |
| 40 | +import io.weaviate.client6.v1.api.collections.query.QueryResponse; |
39 | 41 | import io.weaviate.client6.v1.api.collections.query.QueryResponseGroup; |
| 42 | +import io.weaviate.client6.v1.api.collections.query.QueryResponseGrouped; |
40 | 43 | import io.weaviate.client6.v1.api.collections.query.Rerank; |
41 | 44 | import io.weaviate.client6.v1.api.collections.query.SortBy; |
42 | 45 | import io.weaviate.client6.v1.api.collections.query.Target; |
|
48 | 51 | import io.weaviate.containers.Img2VecNeural; |
49 | 52 | import io.weaviate.containers.Model2Vec; |
50 | 53 | import io.weaviate.containers.Weaviate; |
| 54 | +import io.weaviate.containers.Weaviate.Version; |
51 | 55 |
|
52 | 56 | public class SearchITest extends ConcurrentTest { |
53 | 57 | private static final ContainerGroup compose = Container.compose( |
@@ -839,4 +843,45 @@ public void testVectorizerModel2VecPropeties() throws IOException { |
839 | 843 | Assertions.assertThat(v.getSingle("title_vec")).isEqualTo(v.getSingle("author_vec")); |
840 | 844 | }); |
841 | 845 | } |
| 846 | + |
| 847 | + @Test |
| 848 | + public void testQueryProfile() throws Exception { |
| 849 | + Version.V136.orSkip(); |
| 850 | + |
| 851 | + var things = client.collections.use(COLLECTION); |
| 852 | + var resp = things.query.nearVector(searchVector, |
| 853 | + opt -> opt.distance(10f) |
| 854 | + .returnMetadata(Metadata.QUERY_PROFILE)); |
| 855 | + |
| 856 | + Assertions.assertThat(resp) |
| 857 | + .extracting(QueryResponse::queryProfile).isNotNull() |
| 858 | + .extracting(QueryProfile::shards, InstanceOfAssertFactories.list(QueryProfile.ShardProfile.class)) |
| 859 | + .hasSize(1) |
| 860 | + .allSatisfy(shardProfile -> Assertions.assertThat(shardProfile) |
| 861 | + .extracting(QueryProfile.ShardProfile::searches, |
| 862 | + InstanceOfAssertFactories.map(String.class, String.class)) |
| 863 | + .isNotEmpty()); |
| 864 | + } |
| 865 | + |
| 866 | + @Test |
| 867 | + @Ignore("v1.36.9 does not support query profiles for grouped queries") |
| 868 | + public void testQueryProfile_groupBy() throws Exception { |
| 869 | + Version.V136.orSkip(); |
| 870 | + |
| 871 | + var things = client.collections.use(COLLECTION); |
| 872 | + var resp = things.query.nearVector(searchVector, |
| 873 | + opt -> opt.distance(10f) |
| 874 | + .returnMetadata(Metadata.QUERY_PROFILE), |
| 875 | + GroupBy.property("category", 2, 5)); |
| 876 | + |
| 877 | + Assertions.assertThat(resp) |
| 878 | + .extracting(QueryResponseGrouped::queryProfile).isNotNull() |
| 879 | + .extracting(QueryProfile::shards, |
| 880 | + InstanceOfAssertFactories.list(QueryProfile.ShardProfile.class)) |
| 881 | + .hasSize(1) |
| 882 | + .allSatisfy(shardProfile -> Assertions.assertThat(shardProfile) |
| 883 | + .extracting(QueryProfile.ShardProfile::searches, |
| 884 | + InstanceOfAssertFactories.map(String.class, String.class)) |
| 885 | + .isNotEmpty()); |
| 886 | + } |
842 | 887 | } |
0 commit comments