|
6 | 6 | import io.stargate.sdk.json.domain.odm.Document; |
7 | 7 |
|
8 | 8 | public class ObjectMappingInsertOne { |
9 | | - static class Product { |
10 | | - @JsonProperty("product_name") private String name; |
11 | | - @JsonProperty("product_price") private Double price; |
12 | | - Product(String name, Double price) { |
13 | | - this.name = name; |
14 | | - this.price = price; |
15 | | - } |
16 | | - } |
| 9 | + static class Product { |
| 10 | + @JsonProperty("product_name") private String name; |
| 11 | + @JsonProperty("product_price") private Double price; |
| 12 | + Product(String name, Double price) { |
| 13 | + this.name = name; |
| 14 | + this.price = price; |
| 15 | + } |
| 16 | + } |
17 | 17 |
|
18 | | - public static void main(String[] args) { |
19 | | - AstraDB db = new AstraDB("<token>", "<api_endpoint>"); |
20 | | - AstraDBRepository<Product> productRepository = db |
21 | | - .createCollection("collection_vector1", 14, Product.class); |
22 | | - |
23 | | - // Upsert document |
24 | | - productRepository.save(new Document<Product>() |
25 | | - .id("product1") |
26 | | - .vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f}) |
27 | | - .data(new Product("product1", 9.99))); |
28 | | - } |
| 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); |
29 | 22 |
|
| 23 | + // Upsert document |
| 24 | + productRepository.save(new Document<Product>() |
| 25 | + .id("product1") |
| 26 | + .vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f}) |
| 27 | + .data(new Product("product1", 9.99))); |
| 28 | + } |
30 | 29 | } |
0 commit comments