Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: order-by in scroll #42

Merged
merged 4 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# The version of qdrant to use to download protos
qdrantProtosVersion=v1.9.2
qdrantProtosVersion=v1.9.5

# The version of qdrant docker image to run integration tests against
qdrantVersion=v1.9.2
qdrantVersion=v1.9.5

# The version of the client to generate
packageVersion=1.9.1
96 changes: 68 additions & 28 deletions src/test/java/io/qdrant/client/PointsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import io.qdrant.client.grpc.Collections;
import io.qdrant.client.grpc.Points;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -381,6 +383,44 @@ public void scroll() throws ExecutionException, InterruptedException {
assertFalse(scrollResponse.hasNextPageOffset());
}

@Test
public void scrollWithOrdering() throws ExecutionException, InterruptedException {
createAndSeedCollection(testName);

Collections.PayloadIndexParams params = Collections.PayloadIndexParams.newBuilder()
.setIntegerIndexParams(
Collections.IntegerIndexParams.newBuilder().setLookup(false).setRange(true).build())
.build();

UpdateResult resultIndex = client.createPayloadIndexAsync(
testName,
"bar",
PayloadSchemaType.Integer,
params,
true,
null,
null).get();

assertEquals(UpdateStatus.Completed, resultIndex.getStatus());

CollectionInfo collectionInfo = client.getCollectionInfoAsync(testName).get();
assertEquals(ImmutableSet.of("bar"), collectionInfo.getPayloadSchemaMap().keySet());

ScrollResponse scrollResponse = client.scrollAsync(ScrollPoints.newBuilder()
.setCollectionName(testName)
.setLimit(1)
.setOrderBy(Points.OrderBy.newBuilder()
.setDirection(Points.Direction.Desc)
.setKey("bar").build())
.build()
).get();


assertEquals(1, scrollResponse.getResultCount());
assertFalse(scrollResponse.hasNextPageOffset());
assertEquals(scrollResponse.getResult(0).getId(), id(9));
}

@Test
public void recommend() throws ExecutionException, InterruptedException {
createAndSeedCollection(testName);
Expand Down Expand Up @@ -458,10 +498,10 @@ public void discover() throws ExecutionException, InterruptedException {
createAndSeedCollection(testName);

List<ScoredPoint> points = client.discoverAsync(DiscoverPoints.newBuilder()
.setCollectionName(testName)
.setTarget(targetVector(vector(ImmutableList.of(10.4f, 11.4f))))
.setLimit(1)
.build()).get();
.setCollectionName(testName)
.setTarget(targetVector(vector(ImmutableList.of(10.4f, 11.4f))))
.setLimit(1)
.build()).get();

assertEquals(1, points.size());
assertEquals(id(9), points.get(0).getId());
Expand All @@ -472,19 +512,19 @@ public void discoverBatch() throws ExecutionException, InterruptedException {
createAndSeedCollection(testName);

List<BatchResult> batchResults = client.discoverBatchAsync(
testName,
ImmutableList.of(
DiscoverPoints.newBuilder()
.setCollectionName(testName)
.setTarget(targetVector(vector(ImmutableList.of(10.4f, 11.4f))))
.setLimit(1)
.build(),
DiscoverPoints.newBuilder()
.setCollectionName(testName)
.setTarget(targetVector(vector(ImmutableList.of(3.5f, 4.5f))))
.setLimit(1)
.build()),
null).get();
testName,
ImmutableList.of(
DiscoverPoints.newBuilder()
.setCollectionName(testName)
.setTarget(targetVector(vector(ImmutableList.of(10.4f, 11.4f))))
.setLimit(1)
.build(),
DiscoverPoints.newBuilder()
.setCollectionName(testName)
.setTarget(targetVector(vector(ImmutableList.of(3.5f, 4.5f))))
.setLimit(1)
.build()),
null).get();

assertEquals(2, batchResults.size());
BatchResult result = batchResults.get(0);
Expand Down Expand Up @@ -573,17 +613,17 @@ public void batchPointUpdate() throws ExecutionException, InterruptedException {
createAndSeedCollection(testName);

List<PointsUpdateOperation> operations = List.of(
PointsUpdateOperation.newBuilder()
.setClearPayload(ClearPayload.newBuilder().setPoints(
PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addIds(id(9))))
.build())
.build(),
PointsUpdateOperation.newBuilder()
.setUpdateVectors(UpdateVectors.newBuilder()
.addPoints(PointVectors.newBuilder()
.setId(id(9))
.setVectors(vectors(0.6f, 0.7f))))
.build());
PointsUpdateOperation.newBuilder()
.setClearPayload(ClearPayload.newBuilder().setPoints(
PointsSelector.newBuilder().setPoints(PointsIdsList.newBuilder().addIds(id(9))))
.build())
.build(),
PointsUpdateOperation.newBuilder()
.setUpdateVectors(UpdateVectors.newBuilder()
.addPoints(PointVectors.newBuilder()
.setId(id(9))
.setVectors(vectors(0.6f, 0.7f))))
.build());

List<UpdateResult> response = client.batchUpdateAsync(testName, operations).get();

Expand Down
Loading