mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-27 23:18:29 +02:00
feat: add rust snippets
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
Qdrant, QdrantError,
|
||||
qdrant::{Document, Query, QueryPointsBuilder, Value},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6333").build().unwrap();
|
||||
|
||||
let mut options = HashMap::<String, Value>::new();
|
||||
options.insert("cohere-api-key".to_string(), "<YOUR_COHERE_API_KEY>".into());
|
||||
options.insert("output_dimension".to_string(), 512.into());
|
||||
|
||||
client
|
||||
.query(
|
||||
QueryPointsBuilder::new("<your-collection_name>")
|
||||
.query(Query::new_nearest(Document {
|
||||
text: "a green square".into(),
|
||||
model: "cohere/embed-v4.0".into(),
|
||||
options,
|
||||
}))
|
||||
.build(),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
Payload, Qdrant, QdrantError,
|
||||
qdrant::{Document, PointStruct, UpsertPointsBuilder},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6333").build()?;
|
||||
let mut options = HashMap::new();
|
||||
options.insert("cohere-api-key".to_string(), "<YOUR_COHERE_API_KEY>".into());
|
||||
options.insert("output_dimension".to_string(), 512.into());
|
||||
|
||||
client
|
||||
.upsert_points(UpsertPointsBuilder::new("<your-collection>",
|
||||
vec![
|
||||
PointStruct::new(1,
|
||||
Document {
|
||||
text: "Recipe for baking chocolate chip cookies requires flour, sugar, eggs, and chocolate chips.".into(),
|
||||
model: "openai/text-embedding-3-small".into(),
|
||||
options,
|
||||
},
|
||||
Payload::default())
|
||||
]).wait(true))
|
||||
.await?;
|
||||
```
|
||||
@@ -0,0 +1,23 @@
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
Payload, Qdrant, QdrantError,
|
||||
qdrant::{Document, PointStruct, UpsertPointsBuilder},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6333").build()?;
|
||||
|
||||
client
|
||||
.upsert_points(UpsertPointsBuilder::new("<your-collection>",
|
||||
vec![
|
||||
PointStruct::new(1,
|
||||
HashMap::from([("my-bm25-vector".to_string(),
|
||||
Document {
|
||||
text: "Recipe for baking chocolate chip cookies".into(),
|
||||
model: "qdrant/bm25".into(),
|
||||
options: HashMap::new(),
|
||||
}.into())]),
|
||||
Payload::default())
|
||||
]))
|
||||
.await?;
|
||||
```
|
||||
@@ -0,0 +1,25 @@
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
Qdrant, QdrantError,
|
||||
qdrant::{Document, Query, QueryPointsBuilder, Value},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6333").build().unwrap();
|
||||
|
||||
let mut options = HashMap::<String, Value>::new();
|
||||
options.insert("jina-api-key".to_string(), "<YOUR_JINAAI_API_KEY>".into());
|
||||
options.insert("dimensions".to_string(), 512.into());
|
||||
|
||||
client
|
||||
.query(
|
||||
QueryPointsBuilder::new("<your-collection_name>")
|
||||
.query(Query::new_nearest(Document {
|
||||
text: "Mission to Mars".into(),
|
||||
model: "jinaai/jina-clip-v2".into(),
|
||||
options,
|
||||
}))
|
||||
.build(),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
Payload, Qdrant, QdrantError,
|
||||
qdrant::{Image, PointStruct, UpsertPointsBuilder},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6333").build()?;
|
||||
let mut options = HashMap::new();
|
||||
options.insert("jina-api-key".to_string(), "<YOUR_JINAAI_API_KEY>".into());
|
||||
options.insert("dimensions".to_string(), 512.into());
|
||||
|
||||
client
|
||||
.upsert_points(UpsertPointsBuilder::new("<your-collection>",
|
||||
vec![
|
||||
PointStruct::new(1,
|
||||
Image {
|
||||
image: Some("https://qdrant.tech/example.png".into()),
|
||||
model: "jinaai/jina-clip-v2".into(),
|
||||
options,
|
||||
},
|
||||
Payload::default())
|
||||
]).wait(true))
|
||||
.await?;
|
||||
```
|
||||
@@ -0,0 +1,51 @@
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
Payload, Qdrant, QdrantError,
|
||||
qdrant::{Document, PointStruct, UpsertPointsBuilder, Vectors},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6333").build()?;
|
||||
|
||||
let mut jina_options = HashMap::new();
|
||||
jina_options.insert("jina-api-key".to_string(), "<YOUR_JINAAI_API_KEY>".into());
|
||||
jina_options.insert("dimensions".to_string(), 512.into());
|
||||
|
||||
client
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new(
|
||||
"<your-collection>",
|
||||
vec![PointStruct::new(
|
||||
1,
|
||||
NamedVectors::default()
|
||||
.add_vector(
|
||||
"image",
|
||||
Image {
|
||||
image: Some("https://qdrant.tech/example.png".into()),
|
||||
model: "jinaai/jina-clip-v2".into(),
|
||||
options: jina_options,
|
||||
},
|
||||
)
|
||||
.add_vector(
|
||||
"text",
|
||||
Document {
|
||||
text: "Mars, the red planet".into(),
|
||||
model: "sentence-transformers/all-minilm-l6-v2".into(),
|
||||
options: HashMap::new(),
|
||||
},
|
||||
)
|
||||
.add_vector(
|
||||
"bm25",
|
||||
Document {
|
||||
text: "How to bake cookies?".into(),
|
||||
model: "qdrant/bm25".into(),
|
||||
options: HashMap::new(),
|
||||
},
|
||||
),
|
||||
Payload::default(),
|
||||
)],
|
||||
)
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -0,0 +1,25 @@
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
Qdrant, QdrantError,
|
||||
qdrant::{Document, Query, QueryPointsBuilder, Value},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6333").build().unwrap();
|
||||
|
||||
let mut options = HashMap::<String, Value>::new();
|
||||
options.insert("openai-api-key".to_string(), "<YOUR_OPENAI_API_KEY>".into());
|
||||
options.insert("dimensions".to_string(), 512.into());
|
||||
|
||||
client
|
||||
.query(
|
||||
QueryPointsBuilder::new("<your-collection_name>")
|
||||
.query(Query::new_nearest(Document {
|
||||
text: "How to bake cookies?".into(),
|
||||
model: "openai/text-embedding-3-large".into(),
|
||||
options,
|
||||
}))
|
||||
.build(),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
Payload, Qdrant, QdrantError,
|
||||
qdrant::{Document, PointStruct, UpsertPointsBuilder},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6333").build()?;
|
||||
let mut options = HashMap::new();
|
||||
options.insert("openai-api-key".to_string(), "<YOUR_OPENAI_API_KEY>".into());
|
||||
options.insert("dimensions".to_string(), 512.into());
|
||||
|
||||
client
|
||||
.upsert_points(UpsertPointsBuilder::new("<your-collection>",
|
||||
vec![
|
||||
PointStruct::new(1,
|
||||
Document {
|
||||
text: "Recipe for baking chocolate chip cookies".into(),
|
||||
model: "openai/text-embedding-3-large".into(),
|
||||
options,
|
||||
},
|
||||
Payload::default())
|
||||
]).wait(true))
|
||||
.await?;
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
Qdrant, QdrantError,
|
||||
qdrant::{Document, Query, QueryPointsBuilder},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6333").build().unwrap();
|
||||
|
||||
client
|
||||
.query(
|
||||
QueryPointsBuilder::new("<your-collection_name>")
|
||||
.query(Query::new_nearest(Document {
|
||||
text: "How to bake cookies?".into(),
|
||||
model: "qdrant/bm25".into(),
|
||||
options: HashMap::new(),
|
||||
}))
|
||||
.using("my-bm25-vector")
|
||||
.build(),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
Reference in New Issue
Block a user