Skip to content

Commit eb4f396

Browse files
committed
More model work and new tests
1 parent 3945612 commit eb4f396

27 files changed

+439
-175
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package io.metaloom.qdrant.client;
22

3-
import org.junit.ClassRule;
3+
import org.junit.Rule;
44

55
import io.metaloom.qdrant.container.QDrantContainer;
66

77
public abstract class AbstractContainerTest {
88

9-
@ClassRule
10-
public static QDrantContainer qdrant = new QDrantContainer();
9+
@Rule
10+
public QDrantContainer qdrant = new QDrantContainer();
1111

1212
}

http/src/main/java/io/metaloom/qdrant/client/http/model/collection/filter/Filter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.Arrays;
44
import java.util.List;
55

6+
import com.fasterxml.jackson.annotation.JsonIgnore;
67
import com.fasterxml.jackson.annotation.JsonProperty;
78

89
import io.metaloom.qdrant.client.http.model.RestModel;
@@ -37,6 +38,7 @@ public Filter setShould(List<? extends Condition> should) {
3738
return this;
3839
}
3940

41+
@JsonIgnore
4042
public Filter setShould(Condition... should) {
4143
this.should = Arrays.asList(should);
4244
return this;
@@ -51,6 +53,7 @@ public Filter setMust(List<? extends Condition> must) {
5153
return this;
5254
}
5355

56+
@JsonIgnore
5457
public Filter setMust(Condition... must) {
5558
this.must = Arrays.asList(must);
5659
return this;
@@ -65,6 +68,7 @@ public Filter setMustNot(List<? extends Condition> mustNot) {
6568
return this;
6669
}
6770

71+
@JsonIgnore
6872
public Filter setMustNot(Condition... mustNot) {
6973
this.mustNot = Arrays.asList(mustNot);
7074
return this;

http/src/main/java/io/metaloom/qdrant/client/http/model/collection/filter/condition/HasIdCondition.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.util.List;
66

7+
import com.fasterxml.jackson.annotation.JsonIgnore;
78
import com.fasterxml.jackson.annotation.JsonProperty;
89

910
public class HasIdCondition implements Condition {
@@ -20,6 +21,7 @@ public HasIdCondition setIds(List<Long> ids) {
2021
return this;
2122
}
2223

24+
@JsonIgnore
2325
public HasIdCondition setIds(long... ids) {
2426
this.ids = toList(ids);
2527
return this;

http/src/main/java/io/metaloom/qdrant/client/http/model/point/PointDeletePayloadRequest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import java.util.Arrays;
66
import java.util.List;
77

8+
import com.fasterxml.jackson.annotation.JsonIgnore;
9+
import com.fasterxml.jackson.annotation.JsonProperty;
10+
811
import io.metaloom.qdrant.client.http.model.RestRequestModel;
912
import io.metaloom.qdrant.client.http.model.collection.filter.Filter;
1013

@@ -13,16 +16,19 @@ public class PointDeletePayloadRequest implements RestRequestModel {
1316
/**
1417
* List of payload keys to remove from payload
1518
*/
19+
@JsonProperty("keys")
1620
private List<String> keys;
1721

1822
/**
1923
* Deletes values from each point in this list
2024
*/
25+
@JsonProperty("points")
2126
private List<Long> points;
2227

2328
/**
2429
* Deletes values from points that satisfy this filter condition
2530
*/
31+
@JsonProperty("filter")
2632
private Filter filter;
2733

2834
public List<String> getKeys() {
@@ -34,6 +40,7 @@ public PointDeletePayloadRequest setKeys(List<String> keys) {
3440
return this;
3541
}
3642

43+
@JsonIgnore
3744
public PointDeletePayloadRequest setKeys(String... keys) {
3845
this.keys = Arrays.asList(keys);
3946
return this;
@@ -48,6 +55,7 @@ public PointDeletePayloadRequest setPoints(List<Long> points) {
4855
return this;
4956
}
5057

58+
@JsonIgnore
5159
public PointDeletePayloadRequest setPoints(long... ids) {
5260
this.points = toList(ids);
5361
return this;

http/src/main/java/io/metaloom/qdrant/client/http/model/point/PointSetPayloadRequest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44

55
import java.util.List;
66

7+
import com.fasterxml.jackson.annotation.JsonIgnore;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
710
import io.metaloom.qdrant.client.http.model.RestRequestModel;
811
import io.metaloom.qdrant.client.http.model.collection.filter.Filter;
912

1013
public class PointSetPayloadRequest implements RestRequestModel {
1114

15+
@JsonProperty("payload")
1216
private Payload payload;
1317

18+
@JsonProperty("points")
1419
private List<Long> points;
1520

21+
@JsonProperty("filter")
1622
private Filter filter;
1723

1824
public Payload getPayload() {
@@ -33,6 +39,7 @@ public PointSetPayloadRequest setPoints(List<Long> points) {
3339
return this;
3440
}
3541

42+
@JsonIgnore
3643
public PointSetPayloadRequest setPoints(long... values) {
3744
this.points = toList(values);
3845
return this;

http/src/main/java/io/metaloom/qdrant/client/http/model/point/PointStruct.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import static io.metaloom.qdrant.client.util.QDrantClientUtil.toList;
44

5-
import java.util.List;
6-
5+
import com.fasterxml.jackson.annotation.JsonIgnore;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
77
import com.fasterxml.jackson.core.JacksonException;
88
import com.fasterxml.jackson.databind.JsonNode;
99

@@ -12,8 +12,13 @@
1212

1313
public class PointStruct implements RestModel {
1414

15+
@JsonProperty("id")
1516
private int id;
16-
private List<Float> vector;
17+
18+
@JsonProperty("vector")
19+
private VectorData vector;
20+
21+
@JsonProperty("payload")
1722
private Payload payload;
1823

1924
public int getId() {
@@ -25,17 +30,20 @@ public PointStruct setId(int id) {
2530
return this;
2631
}
2732

28-
public List<Float> getVector() {
33+
public VectorData getVector() {
2934
return vector;
3035
}
3136

32-
public PointStruct setVector(List<Float> vector) {
37+
public PointStruct setVector(VectorData vector) {
3338
this.vector = vector;
3439
return this;
3540
}
3641

42+
@JsonIgnore
3743
public PointStruct setVector(float... vector) {
38-
this.vector = toList(vector);
44+
VectorDataPlain data = new VectorDataPlain();
45+
data.setVector(toList(vector));
46+
this.vector = data;
3947
return this;
4048
}
4149

@@ -48,16 +56,19 @@ public PointStruct setPayload(Payload payload) {
4856
return this;
4957
}
5058

59+
@JsonIgnore
5160
public PointStruct setPayload(JsonNode json) {
5261
this.payload = new Payload().setJson(json);
5362
return this;
5463
}
5564

65+
@JsonIgnore
5666
public PointStruct setPayload(String json) throws JacksonException {
5767
setPayload(Json.toJson(json));
5868
return this;
5969
}
6070

71+
@JsonIgnore
6172
public static PointStruct of(float... vectorComponent) {
6273
PointStruct p = new PointStruct();
6374
p.setVector(vectorComponent);

http/src/main/java/io/metaloom/qdrant/client/http/model/point/PointsBatch.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@
55
import java.util.Arrays;
66
import java.util.List;
77

8+
import com.fasterxml.jackson.annotation.JsonIgnore;
9+
import com.fasterxml.jackson.annotation.JsonProperty;
10+
811
import io.metaloom.qdrant.client.http.model.RestModel;
912

1013
public class PointsBatch implements RestModel {
1114

15+
@JsonProperty("ids")
1216
private List<Long> ids;
17+
18+
@JsonProperty("vectors")
1319
private List<Vector> vectors;
20+
21+
@JsonProperty("payloads")
1422
private List<Payload> payloads;
1523

1624
public List<Long> getIds() {
@@ -31,6 +39,7 @@ public PointsBatch setVectors(List<Vector> vectors) {
3139
return this;
3240
}
3341

42+
@JsonIgnore
3443
public PointsBatch setVectors(Vector... vectors) {
3544
this.vectors = Arrays.asList(vectors);
3645
return this;
@@ -45,11 +54,13 @@ public PointsBatch setPayloads(List<Payload> payloads) {
4554
return this;
4655
}
4756

57+
@JsonIgnore
4858
public PointsBatch setIds(long... ids) {
4959
this.ids = toList(ids);
5060
return this;
5161
}
5262

63+
@JsonIgnore
5364
public PointsBatch setPayloads(Payload... payloads) {
5465
this.payloads = Arrays.asList(payloads);
5566
return this;

http/src/main/java/io/metaloom/qdrant/client/http/model/point/PointsListUpsertRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
import java.util.Arrays;
44
import java.util.List;
55

6+
import com.fasterxml.jackson.annotation.JsonIgnore;
7+
import com.fasterxml.jackson.annotation.JsonProperty;
8+
69
public class PointsListUpsertRequest implements PointsUpsertRequest {
710

11+
@JsonProperty("points")
812
private List<PointStruct> points;
913

1014
public List<PointStruct> getPoints() {
@@ -16,6 +20,7 @@ public PointsListUpsertRequest setPoints(List<PointStruct> points) {
1620
return this;
1721
}
1822

23+
@JsonIgnore
1924
public PointsListUpsertRequest setPoints(PointStruct... points) {
2025
this.points = Arrays.asList(points);
2126
return this;
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package io.metaloom.qdrant.client.http.model.point;
22

3+
import java.util.List;
4+
35
import io.metaloom.qdrant.client.http.model.AbstractResponse;
46

57
public class PointsSearchResponse extends AbstractResponse {
68

7-
private ScoredPoint result;
9+
private List<ScoredPoint> result;
810

9-
public ScoredPoint getResult() {
11+
public List<ScoredPoint> getResult() {
1012
return result;
1113
}
1214

13-
public PointsSearchResponse setResult(ScoredPoint result) {
15+
public PointsSearchResponse setResult(List<ScoredPoint> result) {
1416
this.result = result;
1517
return this;
1618
}
19+
1720
}

http/src/main/java/io/metaloom/qdrant/client/http/model/point/ScoredPoint.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,54 @@
44

55
public class ScoredPoint implements RestModel {
66

7+
private int id;
8+
private long version;
9+
private float score;
10+
private Payload payload;
11+
private Vector vector;
12+
13+
public int getId() {
14+
return id;
15+
}
16+
17+
public ScoredPoint setId(int id) {
18+
this.id = id;
19+
return this;
20+
}
21+
22+
public long getVersion() {
23+
return version;
24+
}
25+
26+
public ScoredPoint setVersion(long version) {
27+
this.version = version;
28+
return this;
29+
}
30+
31+
public float getScore() {
32+
return score;
33+
}
34+
35+
public ScoredPoint setScore(float score) {
36+
this.score = score;
37+
return this;
38+
}
39+
40+
public Payload getPayload() {
41+
return payload;
42+
}
43+
44+
public ScoredPoint setPayload(Payload payload) {
45+
this.payload = payload;
46+
return this;
47+
}
48+
49+
public Vector getVector() {
50+
return vector;
51+
}
52+
53+
public ScoredPoint setVector(Vector vector) {
54+
this.vector = vector;
55+
return this;
56+
}
757
}

0 commit comments

Comments
 (0)