mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-28 15:38:33 +02:00
docs: New Rust SDK snippets for /quickstart, /guides and /cloud (#1051)
This commit is contained in:
@@ -53,12 +53,11 @@ const client = new QdrantClient({
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("xyz-example.eu-central.aws.cloud.qdrant.io:6334")
|
||||
.with_api_key("<paste-your-api-key-here>")
|
||||
.build()
|
||||
.unwrap();
|
||||
let client = Qdrant::from_url("https://xyz-example.eu-central.aws.cloud.qdrant.io:6334")
|
||||
.api_key("<paste-your-api-key-here>")
|
||||
.build()?;
|
||||
```
|
||||
|
||||
```java
|
||||
|
||||
@@ -76,12 +76,11 @@ const client = new QdrantClient({
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("xyz-example.eu-central.aws.cloud.qdrant.io:6334")
|
||||
.with_api_key("<paste-your-api-key-here>")
|
||||
.build()
|
||||
.unwrap();
|
||||
let client = Qdrant::from_url("https://xyz-example.eu-central.aws.cloud.qdrant.io:6334")
|
||||
.api_key("<paste-your-api-key-here>")
|
||||
.build()?;
|
||||
```
|
||||
|
||||
```java
|
||||
|
||||
@@ -215,25 +215,17 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{vectors_config::Config, CreateCollection, Distance, VectorParams, VectorsConfig},
|
||||
};
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".into(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 300,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
shard_number: Some(6),
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(6),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -373,31 +365,27 @@ client.createShardKey("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{CreateCollection, ShardingMethod, shard_key::Key}
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, CreateShardKeyBuilder, CreateShardKeyRequestBuilder, Distance,
|
||||
ShardingMethod, VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".into(),
|
||||
shard_number: Some(1),
|
||||
sharding_method: Some(ShardingMethod::Custom),
|
||||
// ... other collection parameters
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(1)
|
||||
.sharding_method(ShardingMethod::Custom.into()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
client
|
||||
.create_shard_key(
|
||||
"{collection_name}",
|
||||
&Key::Keyword("{shard_key".to_string()),
|
||||
None,
|
||||
None,
|
||||
&[],
|
||||
CreateShardKeyRequestBuilder::new("{collection_name}")
|
||||
.request(CreateShardKeyBuilder::default().shard_key("{shard_key".to_string())),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -514,21 +502,20 @@ client.upsertPoints("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
|
||||
use qdrant_client::qdrant::{PointStruct, WriteOrdering, WriteOrderingType};
|
||||
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
|
||||
use qdrant_client::Payload;
|
||||
|
||||
client
|
||||
.upsert_points_blocking(
|
||||
"{collection_name}",
|
||||
Some(vec![shard_key::Key::String("user_1".into())]),
|
||||
vec![
|
||||
PointStruct::new(
|
||||
1111,
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![PointStruct::new(
|
||||
111,
|
||||
vec![0.1, 0.2, 0.3],
|
||||
Default::default(),
|
||||
),
|
||||
],
|
||||
None,
|
||||
Payload::default(),
|
||||
)],
|
||||
)
|
||||
.shard_key_selector("user_1".to_string()),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -746,27 +733,18 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{vectors_config::Config, CreateCollection, Distance, VectorParams, VectorsConfig},
|
||||
};
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".into(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 300,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
shard_number: Some(6),
|
||||
replication_factor: Some(2),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(6)
|
||||
.replication_factor(2),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -998,28 +976,19 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{vectors_config::Config, CreateCollection, Distance, VectorParams, VectorsConfig},
|
||||
};
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".into(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 300,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
shard_number: Some(6),
|
||||
replication_factor: Some(2),
|
||||
write_consistency_factor: Some(2),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(6)
|
||||
.replication_factor(2)
|
||||
.write_consistency_factor(2),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1139,35 +1108,24 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
read_consistency::Value, Condition, Filter, ReadConsistency, ReadConsistencyType,
|
||||
SearchParams, SearchPoints,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
read_consistency::Value, Condition, Filter, ReadConsistencyType, SearchParamsBuilder,
|
||||
SearchPointsBuilder,
|
||||
};
|
||||
use qdrant_client::{Qdrant, QdrantError};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "{collection_name}".into(),
|
||||
filter: Some(Filter::must([Condition::matches(
|
||||
"city",
|
||||
"London".into(),
|
||||
)])),
|
||||
params: Some(SearchParams {
|
||||
hnsw_ef: Some(128),
|
||||
exact: Some(false),
|
||||
..Default::default()
|
||||
}),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
limit: 3,
|
||||
read_consistency: Some(ReadConsistency {
|
||||
value: Some(Value::Type(ReadConsistencyType::Majority.into())),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3)
|
||||
.filter(Filter::must([Condition::matches(
|
||||
"city",
|
||||
"London".to_string(),
|
||||
)]))
|
||||
.params(SearchParamsBuilder::default().hnsw_ef(128).exact(false))
|
||||
.read_consistency(Value::Type(ReadConsistencyType::Majority.into())),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1285,43 +1243,24 @@ client.upsert("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{PointStruct, WriteOrdering, WriteOrderingType};
|
||||
use serde_json::json;
|
||||
use qdrant_client::qdrant::{
|
||||
PointStruct, UpsertPointsBuilder, WriteOrdering, WriteOrderingType
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.upsert_points_blocking(
|
||||
"{collection_name}",
|
||||
None,
|
||||
vec![
|
||||
PointStruct::new(
|
||||
1,
|
||||
vec![0.9, 0.1, 0.1],
|
||||
json!({
|
||||
"color": "red"
|
||||
})
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
),
|
||||
PointStruct::new(
|
||||
2,
|
||||
vec![0.1, 0.9, 0.1],
|
||||
json!({
|
||||
"color": "green"
|
||||
})
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
),
|
||||
PointStruct::new(
|
||||
3,
|
||||
vec![0.1, 0.1, 0.9],
|
||||
json!({
|
||||
"color": "blue"
|
||||
})
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
),
|
||||
],
|
||||
Some(WriteOrdering {
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
PointStruct::new(1, vec![0.9, 0.1, 0.1], [("color", "red".into())]),
|
||||
PointStruct::new(2, vec![0.1, 0.9, 0.1], [("color", "green".into())]),
|
||||
PointStruct::new(3, vec![0.1, 0.1, 0.9], [("color", "blue".into())]),
|
||||
],
|
||||
)
|
||||
.ordering(WriteOrdering {
|
||||
r#type: WriteOrderingType::Strong.into(),
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -94,46 +94,20 @@ client.upsert("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{client::QdrantClient, qdrant::PointStruct};
|
||||
use serde_json::json;
|
||||
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.upsert_points_blocking(
|
||||
"{collection_name}".to_string(),
|
||||
None,
|
||||
.upsert_points(UpsertPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
PointStruct::new(
|
||||
1,
|
||||
vec![0.9, 0.1, 0.1],
|
||||
json!(
|
||||
{"group_id": "user_1"}
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
),
|
||||
PointStruct::new(
|
||||
2,
|
||||
vec![0.1, 0.9, 0.1],
|
||||
json!(
|
||||
{"group_id": "user_1"}
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
),
|
||||
PointStruct::new(
|
||||
3,
|
||||
vec![0.1, 0.1, 0.9],
|
||||
json!(
|
||||
{"group_id": "user_2"}
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
),
|
||||
PointStruct::new(1, vec![0.9, 0.1, 0.1], [("group_id", "user_1".into())]),
|
||||
PointStruct::new(2, vec![0.1, 0.9, 0.1], [("group_id", "user_1".into())]),
|
||||
PointStruct::new(3, vec![0.1, 0.1, 0.9], [("group_id", "user_2".into())]),
|
||||
],
|
||||
None,
|
||||
)
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -259,25 +233,19 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{Condition, Filter, SearchPoints},
|
||||
};
|
||||
use qdrant_client::qdrant::{Condition, Filter, SearchPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must([Condition::matches(
|
||||
"group_id",
|
||||
"user_1".to_string(),
|
||||
)])),
|
||||
vector: vec![0.1, 0.1, 0.9],
|
||||
limit: 10,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.1, 0.1, 0.9], 10).filter(
|
||||
Filter::must([Condition::matches("group_id", "user_1".to_string())]),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -376,33 +344,19 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
vectors_config::Config, CreateCollection, Distance, HnswConfigDiff, VectorParams,
|
||||
VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, HnswConfigDiffBuilder, VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
hnsw_config: Some(HnswConfigDiff {
|
||||
payload_m: Some(16),
|
||||
m: Some(0),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine))
|
||||
.hnsw_config(HnswConfigDiffBuilder::default().payload_m(16).m(0)),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -474,18 +428,17 @@ client.createPayloadIndex("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{client::QdrantClient, qdrant::FieldType};
|
||||
use qdrant_client::qdrant::{CreateFieldIndexCollectionBuilder, FieldType};
|
||||
use qdrant_client::{Qdrant, QdrantError};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_field_index(
|
||||
.create_field_index(CreateFieldIndexCollectionBuilder::new(
|
||||
"{collection_name}",
|
||||
"group_id",
|
||||
FieldType::Keyword,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
|
||||
|
||||
@@ -77,37 +77,24 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
quantization_config::Quantization, vectors_config::Config, CreateCollection, Distance,
|
||||
OptimizersConfigDiff, QuantizationConfig, QuantizationType, ScalarQuantization,
|
||||
VectorParams, VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, QuantizationType, ScalarQuantizationBuilder,
|
||||
VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
on_disk: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
quantization_config: Some(QuantizationConfig {
|
||||
quantization: Some(Quantization::Scalar(ScalarQuantization {
|
||||
r#type: QuantizationType::Int8.into(),
|
||||
always_ram: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine))
|
||||
.quantization_config(
|
||||
ScalarQuantizationBuilder::default()
|
||||
.r#type(QuantizationType::Int8.into())
|
||||
.always_ram(true),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -214,27 +201,20 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{QuantizationSearchParams, SearchParams, SearchPoints},
|
||||
use qdrant_client::qdrant::{
|
||||
QuantizationSearchParamsBuilder, SearchParamsBuilder, SearchPointsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
params: Some(SearchParams {
|
||||
quantization: Some(QuantizationSearchParams {
|
||||
rescore: Some(false),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
}),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3).params(
|
||||
SearchParamsBuilder::default()
|
||||
.quantization(QuantizationSearchParamsBuilder::default().rescore(false)),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -329,33 +309,19 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
vectors_config::Config, CreateCollection, Distance, HnswConfigDiff, OptimizersConfigDiff,
|
||||
VectorParams, VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, HnswConfigDiffBuilder, VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::{Qdrant, QdrantError};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
on_disk: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
hnsw_config: Some(HnswConfigDiff {
|
||||
on_disk: Some(true),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine).on_disk(true))
|
||||
.hnsw_config(HnswConfigDiffBuilder::default().on_disk(true)),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -480,37 +446,24 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
quantization_config::Quantization, vectors_config::Config, CreateCollection, Distance,
|
||||
OptimizersConfigDiff, QuantizationConfig, QuantizationType, ScalarQuantization,
|
||||
VectorParams, VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, QuantizationType, ScalarQuantizationBuilder,
|
||||
VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
on_disk: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
quantization_config: Some(QuantizationConfig {
|
||||
quantization: Some(Quantization::Scalar(ScalarQuantization {
|
||||
r#type: QuantizationType::Int8.into(),
|
||||
always_ram: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine).on_disk(true))
|
||||
.quantization_config(
|
||||
ScalarQuantizationBuilder::default()
|
||||
.r#type(QuantizationType::Int8.into())
|
||||
.always_ram(true),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -613,25 +566,16 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{SearchParams, SearchPoints},
|
||||
};
|
||||
use qdrant_client::qdrant::{SearchParamsBuilder, SearchPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
params: Some(SearchParams {
|
||||
hnsw_ef: Some(128),
|
||||
exact: Some(false),
|
||||
..Default::default()
|
||||
}),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3)
|
||||
.params(SearchParamsBuilder::default().hnsw_ef(128).exact(false)),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -727,32 +671,21 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
vectors_config::Config, CreateCollection, Distance, OptimizersConfigDiff, VectorParams,
|
||||
VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, OptimizersConfigDiffBuilder, VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
optimizers_config: Some(OptimizersConfigDiff {
|
||||
default_segment_number: Some(16),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine))
|
||||
.optimizers_config(
|
||||
OptimizersConfigDiffBuilder::default().default_segment_number(16),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -845,32 +778,21 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
vectors_config::Config, CreateCollection, Distance, OptimizersConfigDiff, VectorParams,
|
||||
VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, OptimizersConfigDiffBuilder, VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
optimizers_config: Some(OptimizersConfigDiff {
|
||||
default_segment_number: Some(2),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine))
|
||||
.optimizers_config(
|
||||
OptimizersConfigDiffBuilder::default().default_segment_number(2),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
|
||||
@@ -205,35 +205,25 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
quantization_config::Quantization, vectors_config::Config, CreateCollection, Distance,
|
||||
QuantizationConfig, QuantizationType, ScalarQuantization, VectorParams, VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, QuantizationType, ScalarQuantizationBuilder,
|
||||
VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
quantization_config: Some(QuantizationConfig {
|
||||
quantization: Some(Quantization::Scalar(ScalarQuantization {
|
||||
r#type: QuantizationType::Int8.into(),
|
||||
quantile: Some(0.99),
|
||||
always_ram: Some(true),
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine))
|
||||
.quantization_config(
|
||||
ScalarQuantizationBuilder::default()
|
||||
.r#type(QuantizationType::Int8.into())
|
||||
.quantile(0.99)
|
||||
.always_ram(true),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -368,33 +358,19 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
quantization_config::Quantization, vectors_config::Config, BinaryQuantization,
|
||||
CreateCollection, Distance, QuantizationConfig, VectorParams, VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
BinaryQuantizationBuilder, CreateCollectionBuilder, Distance, VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 1536,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
quantization_config: Some(QuantizationConfig {
|
||||
quantization: Some(Quantization::Binary(BinaryQuantization {
|
||||
always_ram: Some(true),
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(1536, Distance::Cosine))
|
||||
.quantization_config(BinaryQuantizationBuilder::new(true)),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -509,35 +485,22 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
quantization_config::Quantization, vectors_config::Config, CompressionRatio,
|
||||
CreateCollection, Distance, ProductQuantization, QuantizationConfig, VectorParams,
|
||||
VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CompressionRatio, CreateCollectionBuilder, Distance, ProductQuantizationBuilder,
|
||||
VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
quantization_config: Some(QuantizationConfig {
|
||||
quantization: Some(Quantization::Product(ProductQuantization {
|
||||
compression: CompressionRatio::X16.into(),
|
||||
always_ram: Some(true),
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine))
|
||||
.quantization_config(
|
||||
ProductQuantizationBuilder::new(CompressionRatio::X16.into()).always_ram(true),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -663,29 +626,22 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{QuantizationSearchParams, SearchParams, SearchPoints},
|
||||
};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
use qdrant_client::qdrant::{QuantizationSearchParamsBuilder, SearchParamsBuilder, SearchPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
params: Some(SearchParams {
|
||||
quantization: Some(QuantizationSearchParams {
|
||||
ignore: Some(false),
|
||||
rescore: Some(true),
|
||||
oversampling: Some(2.0),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
}),
|
||||
limit: 10,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 10).params(
|
||||
SearchParamsBuilder::default().quantization(
|
||||
QuantizationSearchParamsBuilder::default()
|
||||
.ignore(false)
|
||||
.rescore(true)
|
||||
.oversampling(2.0),
|
||||
),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -809,27 +765,20 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{QuantizationSearchParams, SearchParams, SearchPoints},
|
||||
use qdrant_client::qdrant::{
|
||||
QuantizationSearchParamsBuilder, SearchParamsBuilder, SearchPointsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
params: Some(SearchParams {
|
||||
quantization: Some(QuantizationSearchParams {
|
||||
ignore: Some(true),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
}),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3).params(
|
||||
SearchParamsBuilder::default()
|
||||
.quantization(QuantizationSearchParamsBuilder::default().ignore(true)),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -952,37 +901,24 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
quantization_config::Quantization, vectors_config::Config, CreateCollection, Distance,
|
||||
OptimizersConfigDiff, QuantizationConfig, QuantizationType, ScalarQuantization,
|
||||
VectorParams, VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, QuantizationType, ScalarQuantizationBuilder,
|
||||
VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
on_disk: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
quantization_config: Some(QuantizationConfig {
|
||||
quantization: Some(Quantization::Scalar(ScalarQuantization {
|
||||
r#type: QuantizationType::Int8.into(),
|
||||
always_ram: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine).on_disk(true))
|
||||
.quantization_config(
|
||||
ScalarQuantizationBuilder::default()
|
||||
.r#type(QuantizationType::Int8.into())
|
||||
.always_ram(true),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1090,27 +1026,18 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{QuantizationSearchParams, SearchParams, SearchPoints},
|
||||
};
|
||||
use qdrant_client::qdrant::{QuantizationSearchParamsBuilder, SearchParamsBuilder, SearchPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
params: Some(SearchParams {
|
||||
quantization: Some(QuantizationSearchParams {
|
||||
rescore: Some(false),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
}),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3).params(
|
||||
SearchParamsBuilder::default()
|
||||
.quantization(QuantizationSearchParamsBuilder::default().rescore(false)),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1219,37 +1146,24 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
quantization_config::Quantization, vectors_config::Config, CreateCollection, Distance,
|
||||
OptimizersConfigDiff, QuantizationConfig, QuantizationType, ScalarQuantization,
|
||||
VectorParams, VectorsConfig,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, QuantizationType, ScalarQuantizationBuilder,
|
||||
VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
on_disk: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
quantization_config: Some(QuantizationConfig {
|
||||
quantization: Some(Quantization::Scalar(ScalarQuantization {
|
||||
r#type: QuantizationType::Int8.into(),
|
||||
always_ram: Some(false),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine).on_disk(true))
|
||||
.quantization_config(
|
||||
ScalarQuantizationBuilder::default()
|
||||
.r#type(QuantizationType::Int8.into())
|
||||
.always_ram(false),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
|
||||
@@ -77,11 +77,11 @@ const client = new QdrantClient({
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("https://xyz-example.eu-central.aws.cloud.qdrant.io:6334")
|
||||
.with_api_key("<paste-your-api-key-here>")
|
||||
.build()?;
|
||||
let client = Qdrant::from_url("https://xyz-example.eu-central.aws.cloud.qdrant.io:6334")
|
||||
.api_key("<paste-your-api-key-here>")
|
||||
.build()?;
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -184,12 +184,11 @@ const client = new QdrantClient({
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("xyz-example.eu-central.aws.cloud.qdrant.io:6334")
|
||||
.with_api_key("<JWT>")
|
||||
.build()
|
||||
.unwrap();
|
||||
let client = Qdrant::from_url("https://xyz-example.eu-central.aws.cloud.qdrant.io:6334")
|
||||
.api_key("<JWT>")
|
||||
.build()?;
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -475,9 +474,9 @@ const client = new QdrantClient({ url: "https://localhost", port: 6333 });
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("https://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
```
|
||||
|
||||
Certificate rotation is enabled with a default refresh time of one hour. This
|
||||
|
||||
@@ -51,10 +51,10 @@ const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
// The Rust client uses Qdrant's GRPC interface
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -95,20 +95,13 @@ await client.createCollection("test_collection", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{vectors_config::Config, VectorParams, VectorsConfig};
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, VectorParamsBuilder};
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "test_collection".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 4,
|
||||
distance: Distance::Dot.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("test_collection")
|
||||
.vectors_config(VectorParamsBuilder::new(4, Distance::Dot)),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -123,10 +116,10 @@ client.createCollectionAsync("test_collection",
|
||||
```csharp
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
await client.CreateCollectionAsync(
|
||||
collectionName: "test_collection",
|
||||
vectorsConfig: new VectorParams { Size = 4, Distance = Distance.Dot }
|
||||
);
|
||||
await client.CreateCollectionAsync(collectionName: "test_collection", vectorsConfig: new VectorParams
|
||||
{
|
||||
Size = 4, Distance = Distance.Dot
|
||||
});
|
||||
```
|
||||
|
||||
<aside role="status">TypeScript, Rust examples use async/await syntax, so should be used in an async block.</aside>
|
||||
@@ -172,35 +165,20 @@ console.debug(operationInfo);
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::PointStruct;
|
||||
use serde_json::json;
|
||||
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
|
||||
|
||||
let points = vec![
|
||||
PointStruct::new(
|
||||
1,
|
||||
vec![0.05, 0.61, 0.76, 0.74],
|
||||
json!(
|
||||
{"city": "Berlin"}
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
),
|
||||
PointStruct::new(
|
||||
2,
|
||||
vec![0.19, 0.81, 0.75, 0.11],
|
||||
json!(
|
||||
{"city": "London"}
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
),
|
||||
PointStruct::new(1, vec![0.05, 0.61, 0.76, 0.74], [("city", "Berlin".into())]),
|
||||
PointStruct::new(2, vec![0.19, 0.81, 0.75, 0.11], [("city", "London".into())]),
|
||||
PointStruct::new(3, vec![0.36, 0.55, 0.47, 0.94], [("city", "Moscow".into())]),
|
||||
// ..truncated
|
||||
];
|
||||
let operation_info = client
|
||||
.upsert_points_blocking("test_collection".to_string(), None, points, None)
|
||||
|
||||
let response = client
|
||||
.upsert_points(UpsertPointsBuilder::new("test_collection", points).wait(true))
|
||||
.await?;
|
||||
|
||||
dbg!(operation_info);
|
||||
dbg!(response);
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -243,31 +221,43 @@ System.out.println(operationInfo);
|
||||
```csharp
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
var operationInfo = await client.UpsertAsync(
|
||||
collectionName: "test_collection",
|
||||
points: new List<PointStruct>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = 1,
|
||||
Vectors = new float[] { 0.05f, 0.61f, 0.76f, 0.74f },
|
||||
Payload = { ["city"] = "Berlin" }
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 2,
|
||||
Vectors = new float[] { 0.19f, 0.81f, 0.75f, 0.11f },
|
||||
Payload = { ["city"] = "London" }
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 3,
|
||||
Vectors = new float[] { 0.36f, 0.55f, 0.47f, 0.94f },
|
||||
Payload = { ["city"] = "Moscow" }
|
||||
},
|
||||
// Truncated
|
||||
}
|
||||
);
|
||||
var operationInfo = await client.UpsertAsync(collectionName: "test_collection", points: new List<PointStruct>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = 1,
|
||||
Vectors = new float[]
|
||||
{
|
||||
0.05f, 0.61f, 0.76f, 0.74f
|
||||
},
|
||||
Payload = {
|
||||
["city"] = "Berlin"
|
||||
}
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 2,
|
||||
Vectors = new float[]
|
||||
{
|
||||
0.19f, 0.81f, 0.75f, 0.11f
|
||||
},
|
||||
Payload = {
|
||||
["city"] = "London"
|
||||
}
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 3,
|
||||
Vectors = new float[]
|
||||
{
|
||||
0.36f, 0.55f, 0.47f, 0.94f
|
||||
},
|
||||
Payload = {
|
||||
["city"] = "Moscow"
|
||||
}
|
||||
},
|
||||
// Truncated
|
||||
});
|
||||
|
||||
Console.WriteLine(operationInfo);
|
||||
```
|
||||
@@ -284,11 +274,15 @@ operation_id=0 status=<UpdateStatus.COMPLETED: 'completed'>
|
||||
|
||||
```rust
|
||||
PointsOperationResponse {
|
||||
result: Some(UpdateResult {
|
||||
operation_id: 0,
|
||||
status: Completed,
|
||||
}),
|
||||
time: 0.006347708,
|
||||
result: Some(
|
||||
UpdateResult {
|
||||
operation_id: Some(
|
||||
0,
|
||||
),
|
||||
status: Completed,
|
||||
},
|
||||
),
|
||||
time: 0.00094027,
|
||||
}
|
||||
```
|
||||
|
||||
@@ -323,16 +317,12 @@ console.debug(searchResult);
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::SearchPoints;
|
||||
use qdrant_client::qdrant::SearchPointsBuilder;
|
||||
|
||||
let search_result = client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "test_collection".to_string(),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
limit: 3,
|
||||
with_payload: Some(true.into()),
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("test_collection", [0.2, 0.1, 0.9, 0.7], 3).with_payload(true),
|
||||
)
|
||||
.await?;
|
||||
|
||||
dbg!(search_result);
|
||||
@@ -361,159 +351,38 @@ System.out.println(searchResult);
|
||||
```
|
||||
|
||||
```csharp
|
||||
var searchResult = await client.SearchAsync(
|
||||
collectionName: "test_collection",
|
||||
vector: new float[] { 0.2f, 0.1f, 0.9f, 0.7f },
|
||||
limit: 3,
|
||||
payloadSelector: true
|
||||
);
|
||||
var searchResult = await client.SearchAsync(collectionName: "test_collection", vector: new float[]
|
||||
{
|
||||
0.2f, 0.1f, 0.9f, 0.7f
|
||||
}, limit: 3, payloadSelector: true);
|
||||
|
||||
Console.WriteLine(searchResult);
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```python
|
||||
ScoredPoint(id=4, version=0, score=1.362, payload={"city": "New York"}, vector=None),
|
||||
ScoredPoint(id=1, version=0, score=1.273, payload={"city": "Berlin"}, vector=None),
|
||||
ScoredPoint(id=3, version=0, score=1.208, payload={"city": "Moscow"}, vector=None)
|
||||
```
|
||||
|
||||
```typescript
|
||||
```json
|
||||
[
|
||||
{
|
||||
id: 4,
|
||||
version: 0,
|
||||
score: 1.362,
|
||||
payload: null,
|
||||
vector: null,
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
version: 0,
|
||||
score: 1.273,
|
||||
payload: null,
|
||||
vector: null,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
version: 0,
|
||||
score: 1.208,
|
||||
payload: null,
|
||||
vector: null,
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
```rust
|
||||
SearchResponse {
|
||||
result: [
|
||||
ScoredPoint {
|
||||
id: Some(PointId {
|
||||
point_id_options: Some(Num(4)),
|
||||
}),
|
||||
payload: {},
|
||||
score: 1.362,
|
||||
version: 0,
|
||||
vectors: None,
|
||||
},
|
||||
ScoredPoint {
|
||||
id: Some(PointId {
|
||||
point_id_options: Some(Num(1)),
|
||||
}),
|
||||
payload: {},
|
||||
score: 1.273,
|
||||
version: 0,
|
||||
vectors: None,
|
||||
},
|
||||
ScoredPoint {
|
||||
id: Some(PointId {
|
||||
point_id_options: Some(Num(3)),
|
||||
}),
|
||||
payload: {},
|
||||
score: 1.208,
|
||||
version: 0,
|
||||
vectors: None,
|
||||
},
|
||||
],
|
||||
time: 0.003635125,
|
||||
}
|
||||
```
|
||||
|
||||
```java
|
||||
[id {
|
||||
num: 4
|
||||
}
|
||||
payload {
|
||||
key: "city"
|
||||
value {
|
||||
string_value: "New York"
|
||||
}
|
||||
}
|
||||
score: 1.362
|
||||
version: 1
|
||||
, id {
|
||||
num: 1
|
||||
}
|
||||
payload {
|
||||
key: "city"
|
||||
value {
|
||||
string_value: "Berlin"
|
||||
}
|
||||
}
|
||||
score: 1.273
|
||||
version: 1
|
||||
, id {
|
||||
num: 3
|
||||
}
|
||||
payload {
|
||||
key: "city"
|
||||
value {
|
||||
string_value: "Moscow"
|
||||
}
|
||||
}
|
||||
score: 1.208
|
||||
version: 1
|
||||
]
|
||||
```
|
||||
|
||||
```csharp
|
||||
[
|
||||
{
|
||||
"id": {
|
||||
"num": "4"
|
||||
},
|
||||
"payload": {
|
||||
"city": {
|
||||
"stringValue": "New York"
|
||||
}
|
||||
},
|
||||
"id": 4,
|
||||
"version": 0,
|
||||
"score": 1.362,
|
||||
"version": "7"
|
||||
"payload": null,
|
||||
"vector": null
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"num": "1"
|
||||
},
|
||||
"payload": {
|
||||
"city": {
|
||||
"stringValue": "Berlin"
|
||||
}
|
||||
},
|
||||
"id": 1,
|
||||
"version": 0,
|
||||
"score": 1.273,
|
||||
"version": "7"
|
||||
"payload": null,
|
||||
"vector": null
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"num": "3"
|
||||
},
|
||||
"payload": {
|
||||
"city": {
|
||||
"stringValue": "Moscow"
|
||||
}
|
||||
},
|
||||
"id": 3,
|
||||
"version": 0,
|
||||
"score": 1.208,
|
||||
"version": "7"
|
||||
"payload": null,
|
||||
"vector": null
|
||||
}
|
||||
]
|
||||
```
|
||||
@@ -555,19 +424,17 @@ console.debug(searchResult);
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, SearchPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, SearchPointsBuilder};
|
||||
|
||||
let search_result = client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "test_collection".to_string(),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
filter: Some(Filter::all([Condition::matches(
|
||||
"city",
|
||||
"London".to_string(),
|
||||
)])),
|
||||
limit: 2,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("test_collection", [0.2, 0.1, 0.9, 0.7], 3)
|
||||
.filter(Filter::all([Condition::matches(
|
||||
"city",
|
||||
"London".to_string(),
|
||||
)]))
|
||||
.with_payload(true),
|
||||
)
|
||||
.await?;
|
||||
|
||||
dbg!(search_result);
|
||||
@@ -594,95 +461,27 @@ System.out.println(searchResult);
|
||||
```csharp
|
||||
using static Qdrant.Client.Grpc.Conditions;
|
||||
|
||||
var searchResult = await client.SearchAsync(
|
||||
collectionName: "test_collection",
|
||||
vector: new float[] { 0.2f, 0.1f, 0.9f, 0.7f },
|
||||
filter: MatchKeyword("city", "London"),
|
||||
limit: 3,
|
||||
payloadSelector: true
|
||||
);
|
||||
var searchResult = await client.SearchAsync(collectionName: "test_collection", vector: new float[]
|
||||
{
|
||||
0.2f, 0.1f, 0.9f, 0.7f
|
||||
}, filter: MatchKeyword("city", "London"), limit: 3, payloadSelector: true);
|
||||
|
||||
Console.WriteLine(searchResult);
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```python
|
||||
ScoredPoint(id=2, version=0, score=0.871, payload={"city": "London"}, vector=None)
|
||||
```
|
||||
|
||||
```typescript
|
||||
```json
|
||||
[
|
||||
{
|
||||
id: 2,
|
||||
version: 0,
|
||||
score: 0.871,
|
||||
payload: { city: "London" },
|
||||
vector: null,
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
```rust
|
||||
SearchResponse {
|
||||
result: [
|
||||
ScoredPoint {
|
||||
id: Some(
|
||||
PointId {
|
||||
point_id_options: Some(
|
||||
Num(
|
||||
2,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
payload: {
|
||||
"city": Value {
|
||||
kind: Some(
|
||||
StringValue(
|
||||
"London",
|
||||
),
|
||||
),
|
||||
},
|
||||
},
|
||||
score: 0.871,
|
||||
version: 0,
|
||||
vectors: None,
|
||||
{
|
||||
"id": 2,
|
||||
"version": 0,
|
||||
"score": 0.871,
|
||||
"payload": {
|
||||
"city": "London"
|
||||
},
|
||||
],
|
||||
time: 0.004001083,
|
||||
}
|
||||
```
|
||||
|
||||
```java
|
||||
[id {
|
||||
num: 2
|
||||
}
|
||||
payload {
|
||||
key: "city"
|
||||
value {
|
||||
string_value: "London"
|
||||
}
|
||||
}
|
||||
score: 0.871
|
||||
version: 1
|
||||
]
|
||||
```
|
||||
|
||||
```csharp
|
||||
[
|
||||
{
|
||||
"id": {
|
||||
"num": "2"
|
||||
},
|
||||
"payload": {
|
||||
"city": {
|
||||
"stringValue": "London"
|
||||
}
|
||||
},
|
||||
"score": 0.871,
|
||||
"version": "7"
|
||||
}
|
||||
"vector": null
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user