Skip to content

Commit b085b86

Browse files
authored
Merge pull request #121 from djsauble/patch-36
Update ObjectMappingFindVector.java
2 parents f4c2125 + 66d202d commit b085b86

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingFindVector.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,28 @@
66
import io.stargate.sdk.json.domain.Filter;
77
import io.stargate.sdk.json.domain.SelectQuery;
88
import io.stargate.sdk.json.domain.odm.Result;
9-
109
import java.util.List;
1110
import java.util.Optional;
1211

1312
public class ObjectMappingFindVector {
14-
static class Product {
15-
@JsonProperty("product_name") private String name;
16-
@JsonProperty("product_price") private Double price;
17-
}
13+
static class Product {
14+
@JsonProperty("product_name") private String name;
15+
@JsonProperty("product_price") private Double price;
16+
}
1817

19-
public static void main(String[] args) {
20-
AstraDB db = new AstraDB("<token>", "<api_endpoint>");
21-
AstraDBRepository<Product> productRepository = db
22-
.createCollection("collection_vector1", 14, Product.class);
18+
public static void main(String[] args) {
19+
AstraDB db = new AstraDB("<token>", "<api_endpoint>");
20+
AstraDBRepository<Product> productRepository =
21+
db.createCollection("collection_vector1", 14, Product.class);
2322

24-
// Perform a semantic search
25-
float[] embeddings = new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f};
26-
Filter metadataFilter = new Filter().where("product_price").isEqualsTo(9.99);
27-
int maxRecord = 10;
28-
List<Result<Product>> res = productRepository.findVector(embeddings, metadataFilter, maxRecord);
23+
// Perform a semantic search
24+
float[] embeddings = new float[]{1f, 0f, 1f, 1f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f};
25+
Filter metadataFilter = new Filter().where("product_price").isEqualsTo(9.99);
26+
int maxRecord = 10;
27+
List<Result<Product>> res = productRepository.findVector(embeddings, metadataFilter, maxRecord);
2928

30-
// If you do not have max record or metadata filter, you can use the following
31-
productRepository.findVector(embeddings, maxRecord);
32-
productRepository.findVector(embeddings, metadataFilter);
33-
}
29+
// If you do not have max record or metadata filter, you can use the following
30+
productRepository.findVector(embeddings, maxRecord);
31+
productRepository.findVector(embeddings, metadataFilter);
32+
}
3433
}

0 commit comments

Comments
 (0)