Skip to content

Commit 9600bb8

Browse files
authored
Merge pull request #55 from qdrant/1.12.0
1.12.0
2 parents b229554 + f730378 commit 9600bb8

File tree

5 files changed

+178
-5
lines changed

5 files changed

+178
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ build/
1111
.idea/libraries/
1212
.idea/uiDesigner.xml
1313
.idea/codeStyles/codeStyleConfig.xml
14+
.idea/codeStyles/Project.xml
1415
*.iws
1516
*.iml
1617
*.ipr

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ To install the library, add the following lines to your build config file.
3434
<dependency>
3535
<groupId>io.qdrant</groupId>
3636
<artifactId>client</artifactId>
37-
<version>1.11.0</version>
37+
<version>1.12.0</version>
3838
</dependency>
3939
```
4040

4141
#### SBT
4242

4343
```sbt
44-
libraryDependencies += "io.qdrant" % "client" % "1.11.0"
44+
libraryDependencies += "io.qdrant" % "client" % "1.12.0"
4545
```
4646

4747
#### Gradle

gradle.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# The version of qdrant to use to download protos
2-
qdrantProtosVersion=v1.11.0
2+
qdrantProtosVersion=v1.12.0
33

44
# The version of qdrant docker image to run integration tests against
5-
qdrantVersion=v1.11.0
5+
qdrantVersion=v1.12.0
66

77
# The version of the client to generate
8-
packageVersion=1.11.0
8+
packageVersion=1.12.0

src/main/java/io/qdrant/client/QdrantClient.java

+98
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import io.qdrant.client.grpc.Collections.VectorsConfig;
4141
import io.qdrant.client.grpc.CollectionsGrpc;
4242
import io.qdrant.client.grpc.JsonWithInt.Value;
43+
import io.qdrant.client.grpc.Points;
4344
import io.qdrant.client.grpc.Points.BatchResult;
4445
import io.qdrant.client.grpc.Points.ClearPayloadPoints;
4546
import io.qdrant.client.grpc.Points.CountPoints;
@@ -2804,6 +2805,103 @@ public ListenableFuture<List<PointGroup>> queryGroupsAsync(
28042805
future, response -> response.getResult().getGroupsList(), MoreExecutors.directExecutor());
28052806
}
28062807

2808+
/**
2809+
* Perform facet counts. For each value in the field, count the number of points that have this
2810+
* value and match the conditions.
2811+
*
2812+
* @param request the facet counts request
2813+
* @return a new instance of {@link ListenableFuture}
2814+
*/
2815+
public ListenableFuture<List<Points.FacetHit>> facetAsync(Points.FacetCounts request) {
2816+
return facetAsync(request, null);
2817+
}
2818+
2819+
/**
2820+
* Perform facet counts. For each value in the field, count the number of points that have this
2821+
* value and match the conditions.
2822+
*
2823+
* @param request the facet counts request
2824+
* @param timeout the timeout for the call.
2825+
* @return a new instance of {@link ListenableFuture}
2826+
*/
2827+
public ListenableFuture<List<Points.FacetHit>> facetAsync(
2828+
Points.FacetCounts request, @Nullable Duration timeout) {
2829+
Preconditions.checkArgument(
2830+
!request.getCollectionName().isEmpty(), "Collection name must not be empty");
2831+
2832+
logger.debug("Facet on '{}'", request.getCollectionName());
2833+
ListenableFuture<Points.FacetResponse> future = getPoints(timeout).facet(request);
2834+
addLogFailureCallback(future, "Facet");
2835+
return Futures.transform(
2836+
future, Points.FacetResponse::getHitsList, MoreExecutors.directExecutor());
2837+
}
2838+
2839+
// region distance matrix
2840+
2841+
/**
2842+
* Compute distance matrix for sampled points with a pair based output format.
2843+
*
2844+
* @param request the search matrix pairs request
2845+
* @return a new instance of {@link ListenableFuture}
2846+
*/
2847+
public ListenableFuture<Points.SearchMatrixPairs> searchMatrixPairsAsync(
2848+
Points.SearchMatrixPoints request) {
2849+
return searchMatrixPairsAsync(request, null);
2850+
}
2851+
2852+
/**
2853+
* Compute distance matrix for sampled points with a pair based output format.
2854+
*
2855+
* @param request the search matrix pairs request
2856+
* @param timeout the timeout for the call.
2857+
* @return a new instance of {@link ListenableFuture}
2858+
*/
2859+
public ListenableFuture<Points.SearchMatrixPairs> searchMatrixPairsAsync(
2860+
Points.SearchMatrixPoints request, @Nullable Duration timeout) {
2861+
Preconditions.checkArgument(
2862+
!request.getCollectionName().isEmpty(), "Collection name must not be empty");
2863+
2864+
logger.debug("Search matrix pairs on '{}'", request.getCollectionName());
2865+
ListenableFuture<Points.SearchMatrixPairsResponse> future =
2866+
getPoints(timeout).searchMatrixPairs(request);
2867+
addLogFailureCallback(future, "Search matrix pairs");
2868+
return Futures.transform(
2869+
future, Points.SearchMatrixPairsResponse::getResult, MoreExecutors.directExecutor());
2870+
}
2871+
2872+
/**
2873+
* Compute distance matrix for sampled points with an offset based output format
2874+
*
2875+
* @param request the search matrix pairs request
2876+
* @return a new instance of {@link ListenableFuture}
2877+
*/
2878+
public ListenableFuture<Points.SearchMatrixOffsets> searchMatrixOffsetsAsync(
2879+
Points.SearchMatrixPoints request) {
2880+
return searchMatrixOffsetsAsync(request, null);
2881+
}
2882+
2883+
/**
2884+
* Compute distance matrix for sampled points with an offset based output format
2885+
*
2886+
* @param request the search matrix pairs request
2887+
* @param timeout the timeout for the call.
2888+
* @return a new instance of {@link ListenableFuture}
2889+
*/
2890+
public ListenableFuture<Points.SearchMatrixOffsets> searchMatrixOffsetsAsync(
2891+
Points.SearchMatrixPoints request, @Nullable Duration timeout) {
2892+
Preconditions.checkArgument(
2893+
!request.getCollectionName().isEmpty(), "Collection name must not be empty");
2894+
2895+
logger.debug("Search matrix offsets on '{}'", request.getCollectionName());
2896+
ListenableFuture<Points.SearchMatrixOffsetsResponse> future =
2897+
getPoints(timeout).searchMatrixOffsets(request);
2898+
addLogFailureCallback(future, "Search matrix offsets");
2899+
return Futures.transform(
2900+
future, Points.SearchMatrixOffsetsResponse::getResult, MoreExecutors.directExecutor());
2901+
}
2902+
2903+
// endregion
2904+
28072905
// region Snapshot Management
28082906

28092907
/**

src/test/java/io/qdrant/client/PointsTest.java

+74
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,80 @@ public void queryGroups() throws ExecutionException, InterruptedException {
813813
assertEquals(1, groups.stream().filter(g -> g.getHitsCount() == 1).count());
814814
}
815815

816+
@Test
817+
public void searchMatrixOffsets() throws ExecutionException, InterruptedException {
818+
createAndSeedCollection(testName);
819+
820+
Points.SearchMatrixOffsets offsets =
821+
client
822+
.searchMatrixOffsetsAsync(
823+
Points.SearchMatrixPoints.newBuilder()
824+
.setCollectionName(testName)
825+
.setSample(3)
826+
.setLimit(2)
827+
.build())
828+
.get();
829+
830+
// Number of ids matches the limit
831+
assertEquals(2, offsets.getIdsCount());
832+
}
833+
834+
@Test
835+
public void searchMatrixPairs() throws ExecutionException, InterruptedException {
836+
createAndSeedCollection(testName);
837+
838+
Points.SearchMatrixPairs pairs =
839+
client
840+
.searchMatrixPairsAsync(
841+
Points.SearchMatrixPoints.newBuilder()
842+
.setCollectionName(testName)
843+
.setSample(3)
844+
.setLimit(2)
845+
.build())
846+
.get();
847+
848+
// Number of ids matches the limit
849+
assertEquals(2, pairs.getPairsCount());
850+
}
851+
852+
@Test
853+
public void facets() throws ExecutionException, InterruptedException {
854+
createAndSeedCollection(testName);
855+
856+
// create payload index for "foo" field
857+
UpdateResult result =
858+
client
859+
.createPayloadIndexAsync(
860+
testName, "foo", PayloadSchemaType.Keyword, null, null, null, null)
861+
.get();
862+
863+
assertEquals(UpdateStatus.Completed, result.getStatus());
864+
865+
List<Points.FacetHit> facets =
866+
client
867+
.facetAsync(
868+
Points.FacetCounts.newBuilder()
869+
.setCollectionName(testName)
870+
.setKey("foo")
871+
.setLimit(2)
872+
.build())
873+
.get();
874+
875+
// Number of facets matches the limit
876+
assertEquals(2, facets.size());
877+
// validate hits
878+
assertEquals(
879+
1,
880+
facets.stream()
881+
.filter(f -> f.getValue().getStringValue().equals("hello") && f.getCount() == 1)
882+
.count());
883+
assertEquals(
884+
1,
885+
facets.stream()
886+
.filter(f -> f.getValue().getStringValue().equals("goodbye") && f.getCount() == 1)
887+
.count());
888+
}
889+
816890
private void createAndSeedCollection(String collectionName)
817891
throws ExecutionException, InterruptedException {
818892
CreateCollection request =

0 commit comments

Comments
 (0)