mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-09 21:08:31 +02:00
This commit both: - Fixes pre-existing mistakes in snippets, aka wrong code samples. - Adds hidden (`@hide`) statements that do not appear in the docs, but satisfy typecheckers.
41 lines
1.7 KiB
Java
41 lines
1.7 KiB
Java
package com.example.snippets_amalgamation;
|
|
|
|
import static io.qdrant.client.PointIdFactory.id;
|
|
import static io.qdrant.client.ShardKeyFactory.shardKey;
|
|
import static io.qdrant.client.ValueFactory.value;
|
|
import static io.qdrant.client.VectorsFactory.vectors;
|
|
|
|
import io.qdrant.client.QdrantClient;
|
|
import io.qdrant.client.QdrantGrpcClient;
|
|
import io.qdrant.client.grpc.Points.PointStruct;
|
|
import io.qdrant.client.grpc.Points.ShardKeySelector;
|
|
import io.qdrant.client.grpc.Points.UpsertPoints;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
public class Snippet {
|
|
public static void run() throws Exception {
|
|
QdrantClient client =
|
|
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
|
|
|
|
client
|
|
.upsertAsync(
|
|
UpsertPoints.newBuilder()
|
|
.setCollectionName("{collection_name}")
|
|
.addAllPoints(
|
|
List.of(
|
|
PointStruct.newBuilder()
|
|
.setId(id(1))
|
|
.setVectors(vectors(0.9f, 0.1f, 0.1f))
|
|
.putAllPayload(Map.of("group_id", value("user_1")))
|
|
.build()))
|
|
.setShardKeySelector(
|
|
ShardKeySelector.newBuilder()
|
|
.addShardKeys(shardKey("user_1"))
|
|
.setFallback(shardKey("default"))
|
|
.build())
|
|
.build())
|
|
.get();
|
|
}
|
|
}
|