docs: C# snippets

Signed-off-by: Anush008 <anushshetty90@gmail.com>
This commit is contained in:
Anush008
2025-11-14 17:42:18 +05:30
parent 651b209c20
commit 71ec1b2841
46 changed files with 257 additions and 37 deletions
@@ -16,7 +16,7 @@ await client.UpsertAsync(
new() { new() {
Id = 1, Id = 1,
Vectors = new Image() { Vectors = new Image() {
Image = "https://qdrant.tech/example.png", Image_ = "https://qdrant.tech/example.png",
Model = "qdrant/clip-vit-b-32-vision", Model = "qdrant/clip-vit-b-32-vision",
}, },
Payload = { Payload = {
@@ -0,0 +1,21 @@
```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}",
query: new Document()
{
Model = "cohere/embed-v4.0",
Text = "a green square",
Options = { ["cohere-api-key"] = "<YOUR_COHERE_API_KEY>", ["output_dimension"] = 512 },
}
);
```
@@ -14,7 +14,7 @@ client, err := qdrant.NewClient(&qdrant.Config{
}) })
client.Query(ctx, &qdrant.QueryPoints{ client.Query(ctx, &qdrant.QueryPoints{
CollectionName: "<your-collection>", CollectionName: "{collection_name}",
Query: qdrant.NewQueryNearest( Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{ qdrant.NewVectorInputDocument(&qdrant.Document{
Text: "a green square", Text: "a green square",
@@ -1,5 +1,5 @@
```http ```http
POST /collections/<your-collection_name>/points/query POST /collections/{collection_name}/points/query
{ {
"query": { "query": {
"text": "a green square", "text": "a green square",
@@ -8,7 +8,7 @@ client = QdrantClient(
) )
client.query_points( client.query_points(
collection_name="<your_collection_name>", collection_name="{collection_name}",
query=models.Document( query=models.Document(
text="a green square", text="a green square",
model="cohere/embed-v4.0", model="cohere/embed-v4.0",
@@ -13,7 +13,7 @@ options.insert("output_dimension".to_string(), 512.into());
client client
.query( .query(
QueryPointsBuilder::new("<your-collection_name>") QueryPointsBuilder::new("{collection_name}")
.query(Query::new_nearest(Document { .query(Query::new_nearest(Document {
text: "a green square".into(), text: "a green square".into(),
model: "cohere/embed-v4.0".into(), model: "cohere/embed-v4.0".into(),
@@ -0,0 +1,29 @@
```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 Image()
{
Model = "cohere/embed-v4.0",
Image_ =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNk+M9Qz0AEYBxVSF+FAAhKDveksOjmAAAAAElFTkSuQmCC",
Options =
{
["cohere-api-key"] = "<YOUR_COHERE_API_KEY>",
["output_dimension"] = 512,
},
},
},
}
);
```
@@ -14,7 +14,7 @@ client, err := qdrant.NewClient(&qdrant.Config{
}) })
client.Upsert(ctx, &qdrant.UpsertPoints{ client.Upsert(ctx, &qdrant.UpsertPoints{
CollectionName: "<your-collection>", CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{ Points: []*qdrant.PointStruct{
{ {
Id: qdrant.NewIDNum(uint64(1)), Id: qdrant.NewIDNum(uint64(1)),
@@ -1,5 +1,5 @@
```http ```http
PUT /collections/<your-collection_name>/points?wait=true PUT /collections/{collection_name}/points?wait=true
{ {
"points": [ "points": [
{ {
@@ -8,7 +8,7 @@ client = QdrantClient(
) )
client.upsert( client.upsert(
collection_name="<your_collection_name>", collection_name="{collection_name}",
points=[ points=[
models.PointStruct( models.PointStruct(
id=1, id=1,
@@ -11,7 +11,7 @@ options.insert("cohere-api-key".to_string(), "<YOUR_COHERE_API_KEY>".into());
options.insert("output_dimension".to_string(), 512.into()); options.insert("output_dimension".to_string(), 512.into());
client client
.upsert_points(UpsertPointsBuilder::new("<your-collection>", .upsert_points(UpsertPointsBuilder::new("{collection_name}",
vec![ vec![
PointStruct::new(1, PointStruct::new(1,
Document { Document {
@@ -0,0 +1,26 @@
```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>
{
["my-bm25-vector"] = new Document()
{
Model = "qdrant/bm25",
Text = "Recipe for baking chocolate chip cookies",
},
},
},
}
);
```
@@ -14,7 +14,7 @@ client, err := qdrant.NewClient(&qdrant.Config{
}) })
client.Upsert(ctx, &qdrant.UpsertPoints{ client.Upsert(ctx, &qdrant.UpsertPoints{
CollectionName: "<your-collection>", CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{ Points: []*qdrant.PointStruct{
{ {
Id: qdrant.NewIDNum(uint64(1)), Id: qdrant.NewIDNum(uint64(1)),
@@ -1,5 +1,5 @@
```http ```http
PUT /collections/<your-collection_name>/points PUT /collections/{collection_name}/points
{ {
"points": [ "points": [
{ {
@@ -8,7 +8,7 @@ client = QdrantClient(
) )
client.upsert( client.upsert(
collection_name="<your-collection_name", collection_name="{collection_name}",
points=[ points=[
models.PointStruct( models.PointStruct(
id=1, id=1,
@@ -7,7 +7,7 @@ use qdrant_client::{
let client = Qdrant::from_url("<your-qdrant-url>").build()?; let client = Qdrant::from_url("<your-qdrant-url>").build()?;
client client
.upsert_points(UpsertPointsBuilder::new("<your-collection>", .upsert_points(UpsertPointsBuilder::new("{collection_name}",
vec![ vec![
PointStruct::new(1, PointStruct::new(1,
HashMap::from([("my-bm25-vector".to_string(), HashMap::from([("my-bm25-vector".to_string(),
@@ -0,0 +1,21 @@
```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}",
query: new Document()
{
Model = "jinaai/jina-clip-v2",
Text = "Mission to Mars",
Options = { ["jina-api-key"] = "<YOUR_JINAAI_API_KEY>", ["dimensions"] = 512 },
}
);
```
@@ -14,7 +14,7 @@ client, err := qdrant.NewClient(&qdrant.Config{
}) })
client.Query(ctx, &qdrant.QueryPoints{ client.Query(ctx, &qdrant.QueryPoints{
CollectionName: "<your-collection>", CollectionName: "{collection_name}",
Query: qdrant.NewQueryNearest( Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{ qdrant.NewVectorInputDocument(&qdrant.Document{
Text: "Mission to Mars", Text: "Mission to Mars",
@@ -1,5 +1,5 @@
```http ```http
POST /collections/<your-collection_name>/points/query POST /collections/{collection_name}/points/query
{ {
"query": { "query": {
"text": "Mission to Mars", "text": "Mission to Mars",
@@ -8,7 +8,7 @@ client = QdrantClient(
) )
client.query_points( client.query_points(
collection_name="<your_collection_name>", collection_name="{collection_name}",
query=models.Document( query=models.Document(
text="Mission to Mars", text="Mission to Mars",
model="jinaai/jina-clip-v2", model="jinaai/jina-clip-v2",
@@ -13,7 +13,7 @@ options.insert("dimensions".to_string(), 512.into());
client client
.query( .query(
QueryPointsBuilder::new("<your-collection_name>") QueryPointsBuilder::new("{collection_name}")
.query(Query::new_nearest(Document { .query(Query::new_nearest(Document {
text: "Mission to Mars".into(), text: "Mission to Mars".into(),
model: "jinaai/jina-clip-v2".into(), model: "jinaai/jina-clip-v2".into(),
@@ -0,0 +1,28 @@
```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 Document()
{
Model = "jinaai/jina-clip-v2",
Text = "Mission to Mars",
Options = { ["jina-api-key"] = "<YOUR_JINAAI_API_KEY>", ["dimensions"] = 512 },
},
},
}
);
```
@@ -14,7 +14,7 @@ client, err := qdrant.NewClient(&qdrant.Config{
}) })
client.Upsert(ctx, &qdrant.UpsertPoints{ client.Upsert(ctx, &qdrant.UpsertPoints{
CollectionName: "<your-collection>", CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{ Points: []*qdrant.PointStruct{
{ {
Id: qdrant.NewIDNum(uint64(1)), Id: qdrant.NewIDNum(uint64(1)),
@@ -1,5 +1,5 @@
```http ```http
PUT /collections/<your-collection_name>/points?wait=true PUT /collections/{collection_name}/points?wait=true
{ {
"points": [ "points": [
{ {
@@ -8,7 +8,7 @@ client = QdrantClient(
) )
client.upsert( client.upsert(
collection_name="<your_collection_name>", collection_name="{collection_name}",
points=[ points=[
models.PointStruct( models.PointStruct(
id=1, id=1,
@@ -11,7 +11,7 @@ options.insert("jina-api-key".to_string(), "<YOUR_JINAAI_API_KEY>".into());
options.insert("dimensions".to_string(), 512.into()); options.insert("dimensions".to_string(), 512.into());
client client
.upsert_points(UpsertPointsBuilder::new("<your-collection>", .upsert_points(UpsertPointsBuilder::new("{collection_name}",
vec![ vec![
PointStruct::new(1, PointStruct::new(1,
Image { Image {
@@ -0,0 +1,33 @@
```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>
{
["image"] = new Image()
{
Model = "qdrant/bm25",
Image_ = "https://qdrant.tech/example.png",
Options = { ["jina-api-key"] = "<YOUR_JINAAI_API_KEY>", ["dimensions"] = 512 },
},
["text"] = new Document()
{
Model = "sentence-transformers/all-minilm-l6-v2",
Text = "Mars, the red planet",
},
["bm25"] = new Document() { Model = "qdrant/bm25", Text = "Mars, the red planet" },
},
},
}
);
```
@@ -14,7 +14,7 @@ client, err := qdrant.NewClient(&qdrant.Config{
}) })
client.Upsert(ctx, &qdrant.UpsertPoints{ client.Upsert(ctx, &qdrant.UpsertPoints{
CollectionName: "<your-collection>", CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{ Points: []*qdrant.PointStruct{
{ {
Id: qdrant.NewIDNum(uint64(1)), Id: qdrant.NewIDNum(uint64(1)),
@@ -1,5 +1,5 @@
```http ```http
PUT /collections/<your-collection_name>/points?wait=true PUT /collections/{collection_name}/points?wait=true
{ {
"points": [ "points": [
{ {
@@ -8,7 +8,7 @@ client = QdrantClient(
) )
client.upsert( client.upsert(
collection_name="<your_collection_name>", collection_name="{collection_name}",
points=[ points=[
models.PointStruct( models.PointStruct(
id=1, id=1,
@@ -14,7 +14,7 @@ jina_options.insert("dimensions".to_string(), 512.into());
client client
.upsert_points( .upsert_points(
UpsertPointsBuilder::new( UpsertPointsBuilder::new(
"<your-collection>", "{collection_name}",
vec![PointStruct::new( vec![PointStruct::new(
1, 1,
NamedVectors::default() NamedVectors::default()
@@ -0,0 +1,21 @@
```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}",
query: new Document()
{
Model = "openai/text-embedding-3-large",
Text = "How to bake cookies?",
Options = { ["openai-api-key"] = "<YOUR_OPENAI_API_KEY>", ["dimensions"] = 512 },
}
);
```
@@ -14,7 +14,7 @@ client, err := qdrant.NewClient(&qdrant.Config{
}) })
client.Query(ctx, &qdrant.QueryPoints{ client.Query(ctx, &qdrant.QueryPoints{
CollectionName: "<your-collection>", CollectionName: "{collection_name}",
Query: qdrant.NewQueryNearest( Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{ qdrant.NewVectorInputDocument(&qdrant.Document{
Model: "openai/text-embedding-3-large", Model: "openai/text-embedding-3-large",
@@ -1,5 +1,5 @@
```http ```http
POST /collections/<your-collection_name>/points/query POST /collections/{collection_name}/points/query
{ {
"query": { "query": {
"text": "How to bake cookies?", "text": "How to bake cookies?",
@@ -8,7 +8,7 @@ client = QdrantClient(
) )
client.query_points( client.query_points(
collection_name="<your_collection_name>", collection_name="{collection_name}",
query=models.Document( query=models.Document(
text="How to bake cookies?", text="How to bake cookies?",
model="openai/text-embedding-3-large", model="openai/text-embedding-3-large",
@@ -13,7 +13,7 @@ options.insert("dimensions".to_string(), 512.into());
client client
.query( .query(
QueryPointsBuilder::new("<your-collection_name>") QueryPointsBuilder::new("{collection_name}")
.query(Query::new_nearest(Document { .query(Query::new_nearest(Document {
text: "How to bake cookies?".into(), text: "How to bake cookies?".into(),
model: "openai/text-embedding-3-large".into(), model: "openai/text-embedding-3-large".into(),
@@ -0,0 +1,24 @@
```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 Document()
{
Model = "openai/text-embedding-3-large",
Text = "Recipe for baking chocolate chip cookies",
Options = { ["openai-api-key"] = "<YOUR_OPENAI_API_KEY>", ["dimensions"] = 512 },
},
},
}
);
```
@@ -14,7 +14,7 @@ client, err := qdrant.NewClient(&qdrant.Config{
}) })
client.Upsert(ctx, &qdrant.UpsertPoints{ client.Upsert(ctx, &qdrant.UpsertPoints{
CollectionName: "<your-collection>", CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{ Points: []*qdrant.PointStruct{
{ {
Id: qdrant.NewIDNum(uint64(1)), Id: qdrant.NewIDNum(uint64(1)),
@@ -1,5 +1,5 @@
```http ```http
PUT /collections/<your-collection_name>/points?wait=true PUT /collections/{collection_name}/points?wait=true
{ {
"points": [ "points": [
{ {
@@ -8,7 +8,7 @@ client = QdrantClient(
) )
client.upsert( client.upsert(
collection_name="<your_collection_name>", collection_name="{collection_name}",
points=[ points=[
models.PointStruct( models.PointStruct(
id=1, id=1,
@@ -11,7 +11,7 @@ options.insert("openai-api-key".to_string(), "<YOUR_OPENAI_API_KEY>".into());
options.insert("dimensions".to_string(), 512.into()); options.insert("dimensions".to_string(), 512.into());
client client
.upsert_points(UpsertPointsBuilder::new("<your-collection>", .upsert_points(UpsertPointsBuilder::new("{collection_name}",
vec![ vec![
PointStruct::new(1, PointStruct::new(1,
Document { Document {
@@ -0,0 +1,17 @@
```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}",
query: new Document() { Model = "qdrant/bm25", Text = "How to bake cookies?" },
usingVector: "my-bm25-vector"
);
```
@@ -14,7 +14,7 @@ client, err := qdrant.NewClient(&qdrant.Config{
}) })
client.Query(ctx, &qdrant.QueryPoints{ client.Query(ctx, &qdrant.QueryPoints{
CollectionName: "<your-collection>", CollectionName: "{collection_name}",
Query: qdrant.NewQueryNearest( Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{ qdrant.NewVectorInputDocument(&qdrant.Document{
Model: "qdrant/bm25", Model: "qdrant/bm25",
@@ -1,5 +1,5 @@
```http ```http
POST /collections/<your-collection_name>/points/query POST /collections/{collection_name}/points/query
{ {
"query": { "query": {
"text": "How to bake cookies?", "text": "How to bake cookies?",
@@ -8,7 +8,7 @@ client = QdrantClient(
) )
client.query_points( client.query_points(
collection_name="<your_collection_name>", collection_name="{collection_name}",
query=models.Document( query=models.Document(
text="How to bake cookies?", text="How to bake cookies?",
model="Qdrant/bm25", model="Qdrant/bm25",
@@ -8,7 +8,7 @@ let client = Qdrant::from_url("<your-qdrant-url>").build().unwrap();
client client
.query( .query(
QueryPointsBuilder::new("<your-collection_name>") QueryPointsBuilder::new("{collection_name}")
.query(Query::new_nearest(Document { .query(Query::new_nearest(Document {
text: "How to bake cookies?".into(), text: "How to bake cookies?".into(),
model: "qdrant/bm25".into(), model: "qdrant/bm25".into(),