mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-05 10:58:32 +02:00
docs: Java, C# snippets
Signed-off-by: Anush008 <anushshetty90@gmail.com>
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
```csharp
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
var client = new QdrantClient(
|
||||
host: "xyz-example.qdrant.io",
|
||||
port: 6334,
|
||||
https: true,
|
||||
apiKey: "<your-api-key>"
|
||||
);
|
||||
|
||||
await client.QueryAsync(
|
||||
collectionName: "{collection_name}",
|
||||
prefetch:
|
||||
[
|
||||
new()
|
||||
{
|
||||
Query = new Document()
|
||||
{
|
||||
Model = "openai/text-embedding-3-small",
|
||||
Text = "How to bake cookies?",
|
||||
Options = { ["openai-api-key"] = "<YOUR_OPENAI_API_KEY>", ["mrl"] = 64 },
|
||||
},
|
||||
Using = "small",
|
||||
Limit = 1000,
|
||||
},
|
||||
],
|
||||
query: new Document()
|
||||
{
|
||||
Model = "openai/text-embedding-3-small",
|
||||
Text = "How to bake cookies?",
|
||||
Options = { ["openai-api-key"] = "<YOUR_OPENAI_API_KEY>" },
|
||||
},
|
||||
usingVector: "large",
|
||||
limit: 10
|
||||
);
|
||||
```
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
```java
|
||||
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;
|
||||
import io.qdrant.client.grpc.Points.Document;
|
||||
import io.qdrant.client.grpc.Points.PrefetchQuery;
|
||||
import java.util.Map;
|
||||
|
||||
QdrantClient client =
|
||||
new QdrantClient(
|
||||
QdrantGrpcClient.newBuilder("xyz-example.qdrant.io", 6334, true)
|
||||
.withApiKey("<your-api-key")
|
||||
.build());
|
||||
|
||||
client
|
||||
.queryAsync(
|
||||
Points.QueryPoints.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.addPrefetch(
|
||||
PrefetchQuery.newBuilder()
|
||||
.setQuery(
|
||||
nearest(
|
||||
Document.newBuilder()
|
||||
.setModel("openai/text-embedding-3-small")
|
||||
.setText("How to bake cookies?")
|
||||
.putAllOptions(
|
||||
Map.of(
|
||||
"openai-api-key",
|
||||
value("<YOUR_OPENAI_API_KEY>"),
|
||||
"mrl",
|
||||
value(64)))
|
||||
.build()))
|
||||
.setUsing("small")
|
||||
.setLimit(1000)
|
||||
.build())
|
||||
.setQuery(
|
||||
nearest(
|
||||
Document.newBuilder()
|
||||
.setModel("openai/text-embedding-3-small")
|
||||
.setText("How to bake cookies?")
|
||||
.putAllOptions(Map.of("openai-api-key", value("<YOUR_OPENAI_API_KEY>")))
|
||||
.build()))
|
||||
.setUsing("large")
|
||||
.build())
|
||||
.get();
|
||||
```
|
||||
@@ -0,0 +1,37 @@
|
||||
```csharp
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
var client = new QdrantClient(
|
||||
host: "xyz-example.qdrant.io",
|
||||
port: 6334,
|
||||
https: true,
|
||||
apiKey: "<your-api-key>"
|
||||
);
|
||||
|
||||
await client.UpsertAsync(
|
||||
collectionName: "{collection_name}",
|
||||
points: new List<PointStruct>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = 1,
|
||||
Vectors = new Dictionary<string, Vector>
|
||||
{
|
||||
["large"] = new Document()
|
||||
{
|
||||
Model = "openai/text-embedding-3-small",
|
||||
Text = "Recipe for baking chocolate chip cookies",
|
||||
Options = { ["openai-api-key"] = "<YOUR_OPENAI_API_KEY>" },
|
||||
},
|
||||
["small"] = new Document()
|
||||
{
|
||||
Model = "openai/text-embedding-3-small",
|
||||
Text = "Recipe for baking chocolate chip cookies",
|
||||
Options = { ["openai-api-key"] = "<YOUR_OPENAI_API_KEY>", ["mrl"] = 64 },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
```
|
||||
@@ -0,0 +1,52 @@
|
||||
```java
|
||||
import static io.qdrant.client.PointIdFactory.id;
|
||||
import static io.qdrant.client.ValueFactory.value;
|
||||
import static io.qdrant.client.VectorFactory.vector;
|
||||
import static io.qdrant.client.VectorsFactory.namedVectors;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Points.Document;
|
||||
import io.qdrant.client.grpc.Points.PointStruct;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
QdrantClient client =
|
||||
new QdrantClient(
|
||||
QdrantGrpcClient.newBuilder("xyz-example.qdrant.io", 6334, true)
|
||||
.withApiKey("<your-api-key")
|
||||
.build());
|
||||
|
||||
client
|
||||
.upsertAsync(
|
||||
"{collection_name}",
|
||||
List.of(
|
||||
PointStruct.newBuilder()
|
||||
.setId(id(1))
|
||||
.setVectors(
|
||||
namedVectors(
|
||||
Map.of(
|
||||
"large",
|
||||
vector(
|
||||
Document.newBuilder()
|
||||
.setModel("openai/text-embedding-3-small")
|
||||
.setText("Recipe for baking chocolate chip cookies")
|
||||
.putAllOptions(
|
||||
Map.of(
|
||||
"openai-api-key", value("<YOUR_OPENAI_API_KEY>")))
|
||||
.build()),
|
||||
"small",
|
||||
vector(
|
||||
Document.newBuilder()
|
||||
.setModel("openai/text-embedding-3-small")
|
||||
.setText("Recipe for baking chocolate chip cookies")
|
||||
.putAllOptions(
|
||||
Map.of(
|
||||
"openai-api-key",
|
||||
value("<YOUR_OPENAI_API_KEY>"),
|
||||
"mrl",
|
||||
value(64)))
|
||||
.build()))))
|
||||
.build()))
|
||||
.get();
|
||||
```
|
||||
Reference in New Issue
Block a user