Files
landing_page/qdrant-landing/content/documentation/headless/snippets/inference/openai-query/java.java
T
xzfc 74a785218b Fix type-checking errors in snippets (code only, no .md)
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.
2025-11-28 22:02:07 +00:00

39 lines
1.6 KiB
Java

package com.example.snippets_amalgamation;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.ValueFactory.value;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Points.Document;
import io.qdrant.client.grpc.Points.QueryPoints;
import java.util.Map;
public class Snippet {
public static void run() throws Exception {
QdrantClient client =
new QdrantClient(
QdrantGrpcClient.newBuilder("xyz-example.qdrant.io", 6334, true)
.withApiKey("<your-api-key")
.build());
client
.queryAsync(
QueryPoints.newBuilder()
.setCollectionName("{collection_name}")
.setQuery(
nearest(
Document.newBuilder()
.setModel("openai/text-embedding-3-large")
.setText("How to bake cookies?")
.putAllOptions(
Map.of(
"openai-api-key",
value("<YOUR_OPENAI_API_KEY>"),
"dimensions",
value(512)))
.build()))
.build())
.get();
}
}