mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-28 23:48:31 +02:00
docs: New Rust SDK snippets - P2
This commit is contained in:
@@ -78,26 +78,16 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{vectors_config::Config, CreateCollection, Distance, VectorParams, VectorsConfig},
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, VectorParamsBuilder};
|
||||
|
||||
//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()?;
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 100,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(100, Distance::Cosine)),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -210,26 +200,17 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{vectors_config::Config, CreateCollection, Distance, VectorParams, VectorsConfig},
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
|
||||
|
||||
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: 100,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
init_from_collection: Some("{from_collection_name}".to_string()),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(100, Distance::Cosine))
|
||||
.init_from_collection("{from_collection_name}"),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -345,44 +326,25 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
vectors_config::Config, CreateCollection, Distance, VectorParams, VectorParamsMap,
|
||||
VectorsConfig,
|
||||
},
|
||||
use qdrant_client::Qdrant;
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, VectorParamsBuilder, VectorsConfigBuilder,
|
||||
};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let mut vectors_config = VectorsConfigBuilder::default();
|
||||
vectors_config
|
||||
.add_named_vector_params("image", VectorParamsBuilder::new(4, Distance::Dot).build());
|
||||
vectors_config.add_named_vector_params(
|
||||
"text",
|
||||
VectorParamsBuilder::new(8, Distance::Cosine).build(),
|
||||
);
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::ParamsMap(VectorParamsMap {
|
||||
map: [
|
||||
(
|
||||
"image".to_string(),
|
||||
VectorParams {
|
||||
size: 4,
|
||||
distance: Distance::Dot.into(),
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
(
|
||||
"text".to_string(),
|
||||
VectorParams {
|
||||
size: 8,
|
||||
distance: Distance::Cosine.into(),
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
]
|
||||
.into(),
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}").vectors_config(vectors_config),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -506,27 +468,20 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{vectors_config::Config, CreateCollection, Datatype, Distance, VectorParams, VectorsConfig},
|
||||
use qdrant_client::Qdrant;
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Datatype, Distance, VectorParamsBuilder,
|
||||
};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
qdrant_client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".into(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 1024,
|
||||
distance: Distance::Cosine.into(),
|
||||
datatype: Some(Datatype::Uint8.into()),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.await?;
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}").vectors_config(
|
||||
VectorParamsBuilder::new(1024, Distance::Cosine).datatype(Datatype::Uint8),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -625,29 +580,22 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{CreateCollection, SparseVectorConfig, SparseVectorParams},
|
||||
use qdrant_client::Qdrant;
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, SparseVectorParamsBuilder, SparseVectorsConfigBuilder,
|
||||
};
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let mut sparse_vector_config = SparseVectorsConfigBuilder::default();
|
||||
|
||||
sparse_vector_config.add_named_vector_params("text", SparseVectorParamsBuilder::default());
|
||||
|
||||
client
|
||||
.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
sparse_vectors_config: Some(SparseVectorConfig {
|
||||
map: [(
|
||||
"text".to_string(),
|
||||
SparseVectorParams {
|
||||
..Default::default()
|
||||
},
|
||||
)]
|
||||
.into(),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.sparse_vectors_config(sparse_vector_config),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -805,20 +753,13 @@ client.updateCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::OptimizersConfigDiff;
|
||||
use qdrant_client::qdrant::{OptimizersConfigDiffBuilder, UpdateCollectionBuilder};
|
||||
|
||||
client
|
||||
.update_collection(
|
||||
"{collection_name}",
|
||||
Some(&OptimizersConfigDiff {
|
||||
indexing_threshold: Some(10000),
|
||||
..Default::default()
|
||||
}),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
UpdateCollectionBuilder::new("{collection_name}").optimizers_config(
|
||||
OptimizersConfigDiffBuilder::default().indexing_threshold(10000),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -1057,48 +998,33 @@ client.updateCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use qdrant_client::qdrant::{
|
||||
quantization_config_diff::Quantization, vectors_config_diff::Config, HnswConfigDiff,
|
||||
QuantizationConfigDiff, QuantizationType, ScalarQuantization, VectorParamsDiff,
|
||||
VectorsConfigDiff,
|
||||
quantization_config_diff::Quantization, vectors_config_diff::Config, HnswConfigDiffBuilder,
|
||||
QuantizationType, ScalarQuantizationBuilder, UpdateCollectionBuilder, VectorParamsDiffBuilder,
|
||||
VectorParamsDiffMap,
|
||||
};
|
||||
|
||||
client
|
||||
.update_collection(
|
||||
"{collection_name}",
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(&HnswConfigDiff {
|
||||
ef_construct: Some(123),
|
||||
..Default::default()
|
||||
}),
|
||||
Some(&VectorsConfigDiff {
|
||||
config: Some(Config::ParamsMap(
|
||||
qdrant_client::qdrant::VectorParamsDiffMap {
|
||||
map: HashMap::from([(
|
||||
("my_vector".into()),
|
||||
VectorParamsDiff {
|
||||
hnsw_config: Some(HnswConfigDiff {
|
||||
m: Some(32),
|
||||
ef_construct: Some(123),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)]),
|
||||
},
|
||||
UpdateCollectionBuilder::new("{collection_name}")
|
||||
.hnsw_config(HnswConfigDiffBuilder::default().ef_construct(123))
|
||||
.vectors_config(Config::ParamsMap(VectorParamsDiffMap {
|
||||
map: HashMap::from([(
|
||||
("my_vector".into()),
|
||||
VectorParamsDiffBuilder::default()
|
||||
.hnsw_config(HnswConfigDiffBuilder::default().m(32).ef_construct(123))
|
||||
.build(),
|
||||
)]),
|
||||
}))
|
||||
.quantization_config(Quantization::Scalar(
|
||||
ScalarQuantizationBuilder::default()
|
||||
.r#type(QuantizationType::Int8.into())
|
||||
.quantile(0.8)
|
||||
.always_ram(true)
|
||||
.build(),
|
||||
)),
|
||||
}),
|
||||
Some(&QuantizationConfigDiff {
|
||||
quantization: Some(Quantization::Scalar(ScalarQuantization {
|
||||
r#type: QuantizationType::Int8 as i32,
|
||||
quantile: Some(0.8),
|
||||
always_ram: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -1316,17 +1242,12 @@ client.updateCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::OptimizersConfigDiff;
|
||||
use qdrant_client::qdrant::{OptimizersConfigDiffBuilder, UpdateCollectionBuilder};
|
||||
|
||||
client
|
||||
.update_collection(
|
||||
"{collection_name}",
|
||||
Some(&OptimizersConfigDiff::default()),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
UpdateCollectionBuilder::new("{collection_name}")
|
||||
.optimizers_config(OptimizersConfigDiffBuilder::default()),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -1462,7 +1383,14 @@ client.updateCollectionAliases({
|
||||
```
|
||||
|
||||
```rust
|
||||
client.create_alias("example_collection", "production_collection").await?;
|
||||
use qdrant_client::qdrant::CreateAliasBuilder;
|
||||
|
||||
client
|
||||
.create_alias(CreateAliasBuilder::new(
|
||||
"example_collection",
|
||||
"production_collection",
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -1614,8 +1542,15 @@ client.updateCollectionAliases({
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::CreateAliasBuilder;
|
||||
|
||||
client.delete_alias("production_collection").await?;
|
||||
client.create_alias("example_collection", "production_collection").await?;
|
||||
client
|
||||
.create_alias(CreateAliasBuilder::new(
|
||||
"example_collection",
|
||||
"production_collection",
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -1654,9 +1589,9 @@ client.getCollectionAliases("{collection_name}");
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client.list_collection_aliases("{collection_name}").await?;
|
||||
```
|
||||
@@ -1707,9 +1642,9 @@ client.getAliases();
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client.list_aliases().await?;
|
||||
```
|
||||
@@ -1760,9 +1695,9 @@ client.getCollections();
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client.list_collections().await?;
|
||||
```
|
||||
|
||||
@@ -83,28 +83,26 @@ client.recommend("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{Condition, Filter, RecommendPoints, RecommendStrategy},
|
||||
use qdrant_client::Qdrant;
|
||||
use qdrant_client::qdrant::{
|
||||
Condition, Filter, RecommendPointsBuilder, RecommendStrategy,
|
||||
};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.recommend(&RecommendPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
positive: vec![100.into(), 200.into()],
|
||||
positive_vectors: vec![vec![100.0, 231.0].into()],
|
||||
negative: vec![718.into()],
|
||||
negative_vectors: vec![vec![0.2, 0.3, 0.4, 0.5].into()],
|
||||
strategy: Some(RecommendStrategy::AverageVector.into()),
|
||||
filter: Some(Filter::must([Condition::matches(
|
||||
"city",
|
||||
"London".to_string(),
|
||||
)])),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
})
|
||||
.recommend(
|
||||
RecommendPointsBuilder::new("{collection_name}", 3)
|
||||
.add_positive(100)
|
||||
.add_positive(231)
|
||||
.add_positive(vec![0.2, 0.3, 0.4, 0.5])
|
||||
.add_negative(718)
|
||||
.strategy(RecommendStrategy::AverageVector)
|
||||
.filter(Filter::must([Condition::matches(
|
||||
"city",
|
||||
"London".to_string(),
|
||||
)])),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -254,17 +252,16 @@ client.recommend("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::RecommendPoints;
|
||||
use qdrant_client::qdrant::RecommendPointsBuilder;
|
||||
|
||||
client
|
||||
.recommend(&RecommendPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
positive: vec![100.into(), 231.into()],
|
||||
negative: vec![718.into()],
|
||||
using: Some("image".to_string()),
|
||||
limit: 10,
|
||||
..Default::default()
|
||||
})
|
||||
.recommend(
|
||||
RecommendPointsBuilder::new("{collection_name}", 10)
|
||||
.add_positive(100)
|
||||
.add_positive(231)
|
||||
.add_negative(718)
|
||||
.using("image"),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -357,22 +354,20 @@ client.recommend("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{LookupLocation, RecommendPoints};
|
||||
use qdrant_client::qdrant::{LookupLocationBuilder, RecommendPointsBuilder};
|
||||
|
||||
client
|
||||
.recommend(&RecommendPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
positive: vec![100.into(), 231.into()],
|
||||
negative: vec![718.into()],
|
||||
using: Some("image".to_string()),
|
||||
limit: 10,
|
||||
lookup_from: Some(LookupLocation {
|
||||
collection_name: "{external_collection_name}".to_string(),
|
||||
vector_name: Some("{external_vector_name}".to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.recommend(
|
||||
RecommendPointsBuilder::new("{collection_name}", 10)
|
||||
.add_positive(100)
|
||||
.add_positive(231)
|
||||
.add_negative(718)
|
||||
.using("image")
|
||||
.lookup_from(
|
||||
LookupLocationBuilder::new("{external_collection_name}")
|
||||
.vector_name("{external_vector_name}"),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -532,40 +527,34 @@ client.recommend_batch("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{Condition, Filter, RecommendBatchPoints, RecommendPoints},
|
||||
use qdrant_client::qdrant::{
|
||||
Condition, Filter, RecommendBatchPointsBuilder, RecommendPointsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let filter = Filter::must([Condition::matches("city", "London".to_string())]);
|
||||
|
||||
let recommend_queries = vec![
|
||||
RecommendPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
positive: vec![100.into(), 231.into()],
|
||||
negative: vec![718.into()],
|
||||
filter: Some(filter.clone()),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
},
|
||||
RecommendPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
positive: vec![200.into(), 67.into()],
|
||||
negative: vec![300.into()],
|
||||
filter: Some(filter),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
},
|
||||
RecommendPointsBuilder::new("{collection_name}", 3)
|
||||
.add_positive(100)
|
||||
.add_positive(231)
|
||||
.add_negative(718)
|
||||
.filter(filter.clone())
|
||||
.build(),
|
||||
RecommendPointsBuilder::new("{collection_name}", 3)
|
||||
.add_positive(200)
|
||||
.add_positive(67)
|
||||
.add_negative(300)
|
||||
.filter(filter.clone())
|
||||
.build(),
|
||||
];
|
||||
|
||||
client
|
||||
.recommend_batch(&RecommendBatchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
recommend_points: recommend_queries,
|
||||
..Default::default()
|
||||
})
|
||||
.recommend_batch(RecommendBatchPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
recommend_queries,
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -761,45 +750,29 @@ client.discover("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
target_vector::Target, vector_example::Example, ContextExamplePair, DiscoverPoints,
|
||||
TargetVector, VectorExample,
|
||||
},
|
||||
};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
use qdrant_client::qdrant::{target_vector::Target, vector_example::Example, ContextExamplePairBuilder, DiscoverPointsBuilder, VectorExample};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
client
|
||||
.discover(&DiscoverPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
target: Some(TargetVector {
|
||||
target: Some(Target::Single(VectorExample {
|
||||
example: Some(Example::Vector(vec![0.2, 0.1, 0.9, 0.7].into())),
|
||||
})),
|
||||
}),
|
||||
context: vec![
|
||||
ContextExamplePair {
|
||||
positive: Some(VectorExample {
|
||||
example: Some(Example::Id(100.into())),
|
||||
}),
|
||||
negative: Some(VectorExample {
|
||||
example: Some(Example::Id(718.into())),
|
||||
}),
|
||||
},
|
||||
ContextExamplePair {
|
||||
positive: Some(VectorExample {
|
||||
example: Some(Example::Id(200.into())),
|
||||
}),
|
||||
negative: Some(VectorExample {
|
||||
example: Some(Example::Id(300.into())),
|
||||
}),
|
||||
},
|
||||
],
|
||||
limit: 10,
|
||||
..Default::default()
|
||||
})
|
||||
.discover(
|
||||
DiscoverPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
ContextExamplePairBuilder::default()
|
||||
.positive(Example::Id(100.into()))
|
||||
.negative(Example::Id(718.into()))
|
||||
.build(),
|
||||
ContextExamplePairBuilder::default()
|
||||
.positive(Example::Id(200.into()))
|
||||
.negative(Example::Id(300.into()))
|
||||
.build(),
|
||||
],
|
||||
10,
|
||||
)
|
||||
.target(Target::Single(VectorExample {
|
||||
example: Some(Example::Vector(vec![0.2, 0.1, 0.9, 0.7].into())),
|
||||
})),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -961,37 +934,29 @@ client.discover("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{vector_example::Example, ContextExamplePair, DiscoverPoints, VectorExample},
|
||||
use qdrant_client::qdrant::{
|
||||
target_vector::Target, vector_example::Example, ContextExamplePairBuilder,
|
||||
DiscoverPointsBuilder, VectorExample,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.discover(&DiscoverPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
context: vec![
|
||||
ContextExamplePair {
|
||||
positive: Some(VectorExample {
|
||||
example: Some(Example::Id(100.into())),
|
||||
}),
|
||||
negative: Some(VectorExample {
|
||||
example: Some(Example::Id(718.into())),
|
||||
}),
|
||||
},
|
||||
ContextExamplePair {
|
||||
positive: Some(VectorExample {
|
||||
example: Some(Example::Id(200.into())),
|
||||
}),
|
||||
negative: Some(VectorExample {
|
||||
example: Some(Example::Id(300.into())),
|
||||
}),
|
||||
},
|
||||
.discover(DiscoverPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
ContextExamplePairBuilder::default()
|
||||
.positive(Example::Id(100.into()))
|
||||
.negative(Example::Id(718.into()))
|
||||
.build(),
|
||||
ContextExamplePairBuilder::default()
|
||||
.positive(Example::Id(200.into()))
|
||||
.negative(Example::Id(300.into()))
|
||||
.build(),
|
||||
],
|
||||
limit: 10,
|
||||
..Default::default()
|
||||
})
|
||||
10,
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
|
||||
|
||||
@@ -95,22 +95,18 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{Condition, Filter, ScrollPoints},
|
||||
};
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must([
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter::must([
|
||||
Condition::matches("city", "london".to_string()),
|
||||
Condition::matches("color", "red".to_string()),
|
||||
])),
|
||||
..Default::default()
|
||||
})
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -214,17 +210,18 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::should([
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter::should([
|
||||
Condition::matches("city", "london".to_string()),
|
||||
Condition::matches("color", "red".to_string()),
|
||||
])),
|
||||
..Default::default()
|
||||
})
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -321,17 +318,18 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must_not([
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter::must_not([
|
||||
Condition::matches("city", "london".to_string()),
|
||||
Condition::matches("color", "red".to_string()),
|
||||
])),
|
||||
..Default::default()
|
||||
})
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -433,18 +431,16 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter {
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter {
|
||||
must: vec![Condition::matches("city", "London".to_string())],
|
||||
must_not: vec![Condition::matches("color", "red".to_string())],
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -550,18 +546,18 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must_not([Filter::must([
|
||||
Condition::matches("city", "London".to_string()),
|
||||
Condition::matches("color", "red".to_string()),
|
||||
])
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter::must_not([Filter::must(
|
||||
[
|
||||
Condition::matches("city", "London".to_string()),
|
||||
Condition::matches("color", "red".to_string()),
|
||||
],
|
||||
)
|
||||
.into()])),
|
||||
..Default::default()
|
||||
})
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -798,6 +794,8 @@ models.FieldCondition(
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::r#match::MatchValue;
|
||||
|
||||
Condition::matches(
|
||||
"color",
|
||||
!MatchValue::from(vec!["black".to_string(), "yellow".to_string()]),
|
||||
@@ -916,17 +914,14 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::should([Condition::matches(
|
||||
"country.name",
|
||||
"Germany".to_string(),
|
||||
)])),
|
||||
..Default::default()
|
||||
})
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter::should([
|
||||
Condition::matches("country.name", "Germany".to_string()),
|
||||
])),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1014,20 +1009,20 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, Range, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, Range, ScrollPointsBuilder};
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::should([Condition::range(
|
||||
"country.cities[].population",
|
||||
Range {
|
||||
gte: Some(9.0),
|
||||
..Default::default()
|
||||
},
|
||||
)])),
|
||||
..Default::default()
|
||||
})
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter::should([
|
||||
Condition::range(
|
||||
"country.cities[].population",
|
||||
Range {
|
||||
gte: Some(9.0),
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
])),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1113,17 +1108,14 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::should([Condition::matches(
|
||||
"country.cities[].sightseeing",
|
||||
"Osaka Castle".to_string(),
|
||||
)])),
|
||||
..Default::default()
|
||||
})
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter::should([
|
||||
Condition::matches("country.cities[].sightseeing", "Osaka Castle".to_string()),
|
||||
])),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1246,17 +1238,15 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must([
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter::must([
|
||||
Condition::matches("diet[].food", "meat".to_string()),
|
||||
Condition::matches("diet[].likes", true),
|
||||
])),
|
||||
..Default::default()
|
||||
})
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1393,12 +1383,11 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, NestedCondition, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, NestedCondition, ScrollPointsBuilder};
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must([NestedCondition {
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter::must([NestedCondition {
|
||||
key: "diet".to_string(),
|
||||
filter: Some(Filter::must([
|
||||
Condition::matches("food", "meat".to_string()),
|
||||
@@ -1406,8 +1395,7 @@ client
|
||||
])),
|
||||
}
|
||||
.into()])),
|
||||
..Default::default()
|
||||
})
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1553,12 +1541,11 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, NestedCondition, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, NestedCondition, ScrollPointsBuilder};
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must([
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}").filter(Filter::must([
|
||||
NestedCondition {
|
||||
key: "diet".to_string(),
|
||||
filter: Some(Filter::must([
|
||||
@@ -1569,8 +1556,7 @@ client
|
||||
.into(),
|
||||
Condition::has_id([1]),
|
||||
])),
|
||||
..Default::default()
|
||||
})
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1655,9 +1641,9 @@ models.FieldCondition(
|
||||
```
|
||||
|
||||
```rust
|
||||
// If the match string contains a white-space, full text match is performed.
|
||||
// Otherwise a keyword match is performed.
|
||||
Condition::matches("description", "good cheap".to_string())
|
||||
use qdrant_client::qdrant::Condition;
|
||||
|
||||
Condition::matches_text("description", "good cheap")
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -1713,6 +1699,8 @@ models.FieldCondition(
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Range};
|
||||
|
||||
Condition::range(
|
||||
"price",
|
||||
Range {
|
||||
@@ -1794,6 +1782,8 @@ models.FieldCondition(
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, DatetimeRange, Timestamp};
|
||||
|
||||
Condition::datetime_range(
|
||||
"date",
|
||||
DatetimeRange {
|
||||
@@ -1885,6 +1875,8 @@ models.FieldCondition(
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, GeoBoundingBox, GeoPoint};
|
||||
|
||||
Condition::geo_bounding_box(
|
||||
"location",
|
||||
GeoBoundingBox {
|
||||
@@ -1956,6 +1948,8 @@ models.FieldCondition(
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, GeoPoint, GeoRadius};
|
||||
|
||||
Condition::geo_radius(
|
||||
"location",
|
||||
GeoRadius {
|
||||
@@ -2136,6 +2130,8 @@ models.FieldCondition(
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, GeoLineString, GeoPoint, GeoPolygon};
|
||||
|
||||
Condition::geo_polygon(
|
||||
"location",
|
||||
GeoPolygon {
|
||||
@@ -2294,6 +2290,8 @@ models.FieldCondition(
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, ValuesCount};
|
||||
|
||||
Condition::values_count(
|
||||
"comments",
|
||||
ValuesCount {
|
||||
@@ -2354,6 +2352,8 @@ models.IsEmptyCondition(
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::Condition;
|
||||
|
||||
Condition::is_empty("reports")
|
||||
```
|
||||
|
||||
@@ -2402,6 +2402,8 @@ models.IsNullCondition(
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::Condition;
|
||||
|
||||
Condition::is_null("reports")
|
||||
```
|
||||
|
||||
@@ -2462,14 +2464,16 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must([Condition::has_id([1, 3, 5, 7, 9, 11])])),
|
||||
..Default::default()
|
||||
})
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}")
|
||||
.filter(Filter::must([Condition::has_id([1, 3, 5, 7, 9, 11])])),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
|
||||
@@ -57,18 +57,18 @@ client.createPayloadIndex("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{client::QdrantClient, qdrant::FieldType};
|
||||
use qdrant_client::qdrant::{CreateFieldIndexCollectionBuilder, FieldType};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_field_index(
|
||||
.create_field_index(CreateFieldIndexCollectionBuilder::new(
|
||||
"{collection_name}",
|
||||
"name_of_the_field_to_index",
|
||||
FieldType::Keyword,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -178,22 +178,22 @@ client.createPayloadIndex("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
payload_index_params::IndexParams, FieldType, PayloadIndexParams, TextIndexParams,
|
||||
TokenizerType,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
payload_index_params::IndexParams, CreateFieldIndexCollectionBuilder, FieldType,
|
||||
PayloadIndexParams, TextIndexParams, TokenizerType,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_field_index(
|
||||
"{collection_name}",
|
||||
"name_of_the_field_to_index",
|
||||
FieldType::Text,
|
||||
Some(&PayloadIndexParams {
|
||||
CreateFieldIndexCollectionBuilder::new(
|
||||
"{collection_name}",
|
||||
"name_of_the_field_to_index",
|
||||
FieldType::Text,
|
||||
)
|
||||
.field_index_params(PayloadIndexParams {
|
||||
index_params: Some(IndexParams::TextIndexParams(TextIndexParams {
|
||||
tokenizer: TokenizerType::Word as i32,
|
||||
min_token_len: Some(2),
|
||||
@@ -201,7 +201,6 @@ client
|
||||
lowercase: Some(true),
|
||||
})),
|
||||
}),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -348,28 +347,27 @@ client.createPayloadIndex("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
payload_index_params::IndexParams, FieldType, PayloadIndexParams,
|
||||
IntegerIndexParams, TokenizerType,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
payload_index_params::IndexParams, CreateFieldIndexCollectionBuilder, FieldType,
|
||||
IntegerIndexParams, PayloadIndexParams,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_field_index(
|
||||
"{collection_name}",
|
||||
"name_of_the_field_to_index",
|
||||
FieldType::Integer,
|
||||
Some(&PayloadIndexParams {
|
||||
CreateFieldIndexCollectionBuilder::new(
|
||||
"{collection_name}",
|
||||
"name_of_the_field_to_index",
|
||||
FieldType::Integer,
|
||||
)
|
||||
.field_index_params(PayloadIndexParams {
|
||||
index_params: Some(IndexParams::IntegerIndexParams(IntegerIndexParams {
|
||||
lookup: false,
|
||||
range: true,
|
||||
})),
|
||||
}),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -525,32 +523,30 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, SparseIndexConfigBuilder, SparseVectorParamsBuilder,
|
||||
SparseVectorsConfigBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
use qdrant_client::{client::QdrantClient, qdrant::collections::SparseVectorIndexConfig};
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let mut sparse_vectors_config = SparseVectorsConfigBuilder::default();
|
||||
|
||||
client.create_collection(&CreateCollection {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
sparse_vectors_config: Some(SparseVectorConfig {
|
||||
map: [
|
||||
(
|
||||
"splade-model-name".to_string(),
|
||||
SparseVectorParams {
|
||||
index: Some(SparseIndexConfig {
|
||||
on_disk: false,
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
}
|
||||
)
|
||||
].into_iter().collect()
|
||||
}),
|
||||
..Default::default()
|
||||
}).await;
|
||||
sparse_vectors_config.add_named_vector_params(
|
||||
"splade-model-name",
|
||||
SparseVectorParamsBuilder::default()
|
||||
.index(SparseIndexConfigBuilder::default().on_disk(true)),
|
||||
);
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.sparse_vectors_config(sparse_vectors_config),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
|
||||
```java
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
@@ -658,30 +654,24 @@ client.createCollection("{collection_name}", {
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, SparseVectorParamsBuilder,
|
||||
Modifier, sparse_vectors_config::SparseVectorsConfigBuilder
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Modifier, SparseVectorParamsBuilder, SparseVectorsConfigBuilder,
|
||||
};
|
||||
use qdrant_client::qdrant::;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
use qdrant_client::{Qdrant, QdrantError};
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let mut sparse_vectors_config = SparseVectorsConfigBuilder::default();
|
||||
|
||||
sparse_vectors_config.add_named_vector_params(
|
||||
"text",
|
||||
SparseVectorParamsBuilder::default()
|
||||
.modifier(Modifier::Idf),
|
||||
SparseVectorParamsBuilder::default().modifier(Modifier::Idf),
|
||||
);
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.sparse_vectors_config(sparse_vectors_config)
|
||||
.sparse_vectors_config(sparse_vectors_config),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -271,43 +271,33 @@ client.upsert("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{client::QdrantClient, qdrant::PointStruct};
|
||||
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
|
||||
use qdrant_client::{Payload, Qdrant, QdrantError};
|
||||
use serde_json::json;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let points = vec![
|
||||
PointStruct::new(
|
||||
1,
|
||||
vec![0.05, 0.61, 0.76, 0.74],
|
||||
json!(
|
||||
{"city": "Berlin", "price": 1.99}
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
Payload::try_from(json!({"city": "Berlin", "price": 1.99})).unwrap(),
|
||||
),
|
||||
PointStruct::new(
|
||||
2,
|
||||
vec![0.19, 0.81, 0.75, 0.11],
|
||||
json!(
|
||||
{"city": ["Berlin", "London"]}
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
Payload::try_from(json!({"city": ["Berlin", "London"]})).unwrap(),
|
||||
),
|
||||
PointStruct::new(
|
||||
3,
|
||||
vec![0.36, 0.55, 0.47, 0.94],
|
||||
json!(
|
||||
{"city": ["Berlin", "Moscow"], "price": [1.99, 2.99]}
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
Payload::try_from(json!({"city": ["Berlin", "Moscow"], "price": [1.99, 2.99]}))
|
||||
.unwrap(),
|
||||
),
|
||||
];
|
||||
|
||||
client
|
||||
.upsert_points("{collection_name}".to_string(), None, points, None)
|
||||
.upsert_points(UpsertPointsBuilder::new("{collection_name}", points).wait(true))
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -437,26 +427,25 @@ client.setPayload("{collection_name}", {
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector,
|
||||
PointsIdsList, SetPayloadPointsBuilder,
|
||||
};
|
||||
use qdrant_client::Payload,;
|
||||
use serde_json::json;
|
||||
|
||||
client
|
||||
.set_payload_blocking(
|
||||
"{collection_name}",
|
||||
None,
|
||||
&PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList {
|
||||
ids: vec![0.into(), 3.into(), 10.into()],
|
||||
})),
|
||||
},
|
||||
json!({
|
||||
"property1": "string",
|
||||
"property2": "string",
|
||||
.set_payload(
|
||||
SetPayloadPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
Payload::try_from(json!({
|
||||
"property1": "string",
|
||||
"property2": "string",
|
||||
}))
|
||||
.unwrap(),
|
||||
)
|
||||
.points_selector(PointsIdsList {
|
||||
ids: vec![0.into(), 3.into(), 10.into()],
|
||||
})
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
None,
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -553,27 +542,25 @@ client.setPayload("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
points_selector::PointsSelectorOneOf, Condition, Filter, PointsSelector,
|
||||
};
|
||||
use qdrant_client::qdrant::{Condition, Filter, SetPayloadPointsBuilder};
|
||||
use qdrant_client::Payload;
|
||||
use serde_json::json;
|
||||
|
||||
client
|
||||
.set_payload_blocking(
|
||||
"{collection_name}",
|
||||
None,
|
||||
&PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Filter(Filter::must([
|
||||
Condition::matches("color", "red".to_string()),
|
||||
]))),
|
||||
},
|
||||
json!({
|
||||
"property1": "string",
|
||||
"property2": "string",
|
||||
})
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
None,
|
||||
.set_payload(
|
||||
SetPayloadPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
Payload::try_from(json!({
|
||||
"property1": "string",
|
||||
"property2": "string",
|
||||
}))
|
||||
.unwrap(),
|
||||
)
|
||||
.points_selector(Filter::must([Condition::matches(
|
||||
"color",
|
||||
"red".to_string(),
|
||||
)]))
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -693,27 +680,24 @@ client.overwritePayload("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector,
|
||||
};
|
||||
use qdrant_client::qdrant::{PointsIdsList, SetPayloadPointsBuilder};
|
||||
use qdrant_client::Payload;
|
||||
use serde_json::json;
|
||||
|
||||
client
|
||||
.overwrite_payload_blocking(
|
||||
"{collection_name}",
|
||||
None,
|
||||
&PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList {
|
||||
ids: vec![0.into(), 3.into(), 10.into()],
|
||||
})),
|
||||
},
|
||||
json!({
|
||||
"property1": "string",
|
||||
"property2": "string",
|
||||
.overwrite_payload(
|
||||
SetPayloadPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
Payload::try_from(json!({
|
||||
"property1": "string",
|
||||
"property2": "string",
|
||||
}))
|
||||
.unwrap(),
|
||||
)
|
||||
.points_selector(PointsIdsList {
|
||||
ids: vec![0.into(), 3.into(), 10.into()],
|
||||
})
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
None,
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -778,20 +762,15 @@ client.clearPayload("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector,
|
||||
};
|
||||
use qdrant_client::qdrant::{ClearPayloadPointsBuilder, PointsIdsList};
|
||||
|
||||
client
|
||||
.clear_payload(
|
||||
"{collection_name}",
|
||||
None,
|
||||
Some(PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList {
|
||||
ids: vec![0.into(), 3.into(), 100.into()],
|
||||
})),
|
||||
}),
|
||||
None,
|
||||
ClearPayloadPointsBuilder::new("{collection_name}")
|
||||
.points(PointsIdsList {
|
||||
ids: vec![0.into(), 3.into(), 10.into()],
|
||||
})
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -848,21 +827,18 @@ client.deletePayload("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector,
|
||||
};
|
||||
use qdrant_client::qdrant::{DeletePayloadPointsBuilder, PointsIdsList};
|
||||
|
||||
client
|
||||
.delete_payload_blocking(
|
||||
"{collection_name}",
|
||||
None,
|
||||
&PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList {
|
||||
ids: vec![0.into(), 3.into(), 100.into()],
|
||||
})),
|
||||
},
|
||||
vec!["color".to_string(), "price".to_string()],
|
||||
None,
|
||||
.delete_payload(
|
||||
DeletePayloadPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec!["color".to_string(), "price".to_string()],
|
||||
)
|
||||
.points_selector(PointsIdsList {
|
||||
ids: vec![0.into(), 3.into(), 10.into()],
|
||||
})
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -947,21 +923,19 @@ client.deletePayload("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
points_selector::PointsSelectorOneOf, Condition, Filter, PointsSelector,
|
||||
};
|
||||
use qdrant_client::qdrant::{Condition, DeletePayloadPointsBuilder, Filter};
|
||||
|
||||
client
|
||||
.delete_payload_blocking(
|
||||
"{collection_name}",
|
||||
None,
|
||||
&PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Filter(Filter::must([
|
||||
Condition::matches("color", "red".to_string()),
|
||||
]))),
|
||||
},
|
||||
vec!["color".to_string(), "price".to_string()],
|
||||
None,
|
||||
.delete_payload(
|
||||
DeletePayloadPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec!["color".to_string(), "price".to_string()],
|
||||
)
|
||||
.points_selector(Filter::must([Condition::matches(
|
||||
"color",
|
||||
"red".to_string(),
|
||||
)]))
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -1034,15 +1008,16 @@ client.createPayloadIndex("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::FieldType;
|
||||
use qdrant_client::qdrant::{CreateFieldIndexCollectionBuilder, FieldType};
|
||||
|
||||
client
|
||||
.create_field_index(
|
||||
"{collection_name}",
|
||||
"name_of_the_field_to_index",
|
||||
FieldType::Keyword,
|
||||
None,
|
||||
None,
|
||||
CreateFieldIndexCollectionBuilder::new(
|
||||
"{collection_name}",
|
||||
"name_of_the_field_to_index",
|
||||
FieldType::Keyword,
|
||||
)
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -96,25 +96,22 @@ 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,
|
||||
vec![PointStruct::new(
|
||||
"5c56c793-69f3-4fbf-87e6-c4bf54c28c26".to_string(),
|
||||
vec![0.05, 0.61, 0.76, 0.74],
|
||||
json!(
|
||||
{"color": "Red"}
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
)],
|
||||
None,
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![PointStruct::new(
|
||||
"5c56c793-69f3-4fbf-87e6-c4bf54c28c26",
|
||||
vec![0.9, 0.1, 0.1],
|
||||
[("color", "Red".into())],
|
||||
)],
|
||||
)
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -212,23 +209,22 @@ client.upsert("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::PointStruct;
|
||||
use serde_json::json;
|
||||
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.upsert_points_blocking(
|
||||
1,
|
||||
None,
|
||||
vec![PointStruct::new(
|
||||
"5c56c793-69f3-4fbf-87e6-c4bf54c28c26".to_string(),
|
||||
vec![0.05, 0.61, 0.76, 0.74],
|
||||
json!(
|
||||
{"color": "Red"}
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
)],
|
||||
None,
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![PointStruct::new(
|
||||
1,
|
||||
vec![0.9, 0.1, 0.1],
|
||||
[("color", "Red".into())],
|
||||
)],
|
||||
)
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -442,44 +438,19 @@ client.upsert("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::PointStruct;
|
||||
use serde_json::json;
|
||||
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
|
||||
|
||||
client
|
||||
.upsert_points_batch_blocking(
|
||||
"{collection_name}".to_string(),
|
||||
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(),
|
||||
),
|
||||
],
|
||||
None,
|
||||
100,
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
PointStruct::new(1, vec![0.9, 0.1, 0.1], [("city", "red".into())]),
|
||||
PointStruct::new(2, vec![0.1, 0.9, 0.1], [("city", "green".into())]),
|
||||
PointStruct::new(3, vec![0.1, 0.1, 0.9], [("city", "blue".into())]),
|
||||
],
|
||||
)
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -694,38 +665,41 @@ client.upsert("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::PointStruct;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
|
||||
use qdrant_client::Payload;
|
||||
|
||||
client
|
||||
.upsert_points_blocking(
|
||||
"{collection_name}".to_string(),
|
||||
None,
|
||||
vec![
|
||||
PointStruct::new(
|
||||
1,
|
||||
HashMap::from([
|
||||
("image".to_string(), vec![0.9, 0.1, 0.1, 0.2]),
|
||||
(
|
||||
"text".to_string(),
|
||||
vec![0.4, 0.7, 0.1, 0.8, 0.1, 0.1, 0.9, 0.2],
|
||||
),
|
||||
]),
|
||||
HashMap::new().into(),
|
||||
),
|
||||
PointStruct::new(
|
||||
2,
|
||||
HashMap::from([
|
||||
("image".to_string(), vec![0.2, 0.1, 0.3, 0.9]),
|
||||
(
|
||||
"text".to_string(),
|
||||
vec![0.5, 0.2, 0.7, 0.4, 0.7, 0.2, 0.3, 0.9],
|
||||
),
|
||||
]),
|
||||
HashMap::new().into(),
|
||||
),
|
||||
],
|
||||
None,
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
PointStruct::new(
|
||||
1,
|
||||
HashMap::from([
|
||||
("image".to_string(), vec![0.9, 0.1, 0.1, 0.2]),
|
||||
(
|
||||
"text".to_string(),
|
||||
vec![0.4, 0.7, 0.1, 0.8, 0.1, 0.1, 0.9, 0.2],
|
||||
),
|
||||
]),
|
||||
Payload::default(),
|
||||
),
|
||||
PointStruct::new(
|
||||
2,
|
||||
HashMap::from([
|
||||
("image".to_string(), vec![0.2, 0.1, 0.3, 0.9]),
|
||||
(
|
||||
"text".to_string(),
|
||||
vec![0.5, 0.2, 0.7, 0.4, 0.7, 0.2, 0.3, 0.9],
|
||||
),
|
||||
]),
|
||||
Payload::default(),
|
||||
),
|
||||
],
|
||||
)
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -926,39 +900,32 @@ client.upsert("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{PointStruct, Vector};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder, Vector};
|
||||
use qdrant_client::Payload;
|
||||
|
||||
client
|
||||
.upsert_points_blocking(
|
||||
"{collection_name}".to_string(),
|
||||
vec![
|
||||
PointStruct::new(
|
||||
1,
|
||||
HashMap::from([
|
||||
(
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
PointStruct::new(
|
||||
1,
|
||||
HashMap::from([("text".to_string(), vec![(6, 1.0), (7, 2.0)])]),
|
||||
Payload::default(),
|
||||
),
|
||||
PointStruct::new(
|
||||
2,
|
||||
HashMap::from([(
|
||||
"text".to_string(),
|
||||
Vector::from(
|
||||
(vec![6, 7], vec![1.0, 2.0])
|
||||
),
|
||||
),
|
||||
]),
|
||||
HashMap::new().into(),
|
||||
),
|
||||
PointStruct::new(
|
||||
2,
|
||||
HashMap::from([
|
||||
(
|
||||
"text".to_string(),
|
||||
Vector::from(
|
||||
(vec![1, 2, 3, 4, 5], vec![0.1, 0.2, 0.3, 0.4, 0.5])
|
||||
),
|
||||
),
|
||||
]),
|
||||
HashMap::new().into(),
|
||||
),
|
||||
],
|
||||
None,
|
||||
vec![(1, 0.1), (2, 0.2), (3, 0.3), (4, 0.4), (5, 0.5)],
|
||||
)]),
|
||||
Payload::default(),
|
||||
),
|
||||
],
|
||||
)
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -1109,32 +1076,36 @@ client.updateVectors("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::PointVectors;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use qdrant_client::qdrant::{
|
||||
PointVectors, UpdatePointVectorsBuilder,
|
||||
};
|
||||
|
||||
client
|
||||
.update_vectors_blocking(
|
||||
"{collection_name}",
|
||||
None,
|
||||
&[
|
||||
PointVectors {
|
||||
id: Some(1.into()),
|
||||
vectors: Some(
|
||||
HashMap::from([("image".to_string(), vec![0.1, 0.2, 0.3, 0.4])]).into(),
|
||||
),
|
||||
},
|
||||
PointVectors {
|
||||
id: Some(2.into()),
|
||||
vectors: Some(
|
||||
HashMap::from([(
|
||||
"text".to_string(),
|
||||
vec![0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2],
|
||||
)])
|
||||
.into(),
|
||||
),
|
||||
},
|
||||
],
|
||||
None,
|
||||
.update_vectors(
|
||||
UpdatePointVectorsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
PointVectors {
|
||||
id: Some(1.into()),
|
||||
vectors: Some(
|
||||
HashMap::from([("image".to_string(), vec![0.1, 0.2, 0.3, 0.4])]).into(),
|
||||
),
|
||||
},
|
||||
PointVectors {
|
||||
id: Some(2.into()),
|
||||
vectors: Some(
|
||||
HashMap::from([(
|
||||
"text".to_string(),
|
||||
vec![0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2],
|
||||
)])
|
||||
.into(),
|
||||
),
|
||||
},
|
||||
],
|
||||
)
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -1222,22 +1193,17 @@ client.deleteVectors("{collection_name}", {
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector, VectorsSelector,
|
||||
DeletePointVectorsBuilder, PointsIdsList,
|
||||
};
|
||||
|
||||
client
|
||||
.delete_vectors_blocking(
|
||||
"{collection_name}",
|
||||
None,
|
||||
&PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList {
|
||||
.delete_vectors(
|
||||
DeletePointVectorsBuilder::new("{collection_name}")
|
||||
.points_selector(PointsIdsList {
|
||||
ids: vec![0.into(), 3.into(), 10.into()],
|
||||
})),
|
||||
},
|
||||
&VectorsSelector {
|
||||
names: vec!["text".into(), "image".into()],
|
||||
},
|
||||
None,
|
||||
})
|
||||
.vectors(vec!["text".into(), "image".into()])
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -1286,20 +1252,15 @@ client.delete("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
points_selector::PointsSelectorOneOf, PointsIdsList, PointsSelector,
|
||||
};
|
||||
use qdrant_client::qdrant::{DeletePointsBuilder, PointsIdsList};
|
||||
|
||||
client
|
||||
.delete_points_blocking(
|
||||
"{collection_name}",
|
||||
None,
|
||||
&PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList {
|
||||
.delete_points(
|
||||
DeletePointsBuilder::new("{collection_name}")
|
||||
.points(PointsIdsList {
|
||||
ids: vec![0.into(), 3.into(), 100.into()],
|
||||
})),
|
||||
},
|
||||
None,
|
||||
})
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -1370,20 +1331,16 @@ client.delete("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
points_selector::PointsSelectorOneOf, Condition, Filter, PointsSelector,
|
||||
};
|
||||
use qdrant_client::qdrant::{Condition, DeletePointsBuilder, Filter};
|
||||
|
||||
client
|
||||
.delete_points_blocking(
|
||||
"{collection_name}",
|
||||
None,
|
||||
&PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Filter(Filter::must([
|
||||
Condition::matches("color", "red".to_string()),
|
||||
]))),
|
||||
},
|
||||
None,
|
||||
.delete_points(
|
||||
DeletePointsBuilder::new("{collection_name}")
|
||||
.points(Filter::must([Condition::matches(
|
||||
"color",
|
||||
"red".to_string(),
|
||||
)]))
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -1438,15 +1395,13 @@ client.retrieve("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::GetPointsBuilder;
|
||||
|
||||
client
|
||||
.get_points(
|
||||
.get_points(GetPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
None,
|
||||
&[0.into(), 30.into(), 100.into()],
|
||||
Some(false),
|
||||
Some(false),
|
||||
None,
|
||||
)
|
||||
vec![0.into(), 30.into(), 100.into()],
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1550,20 +1505,19 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPoints};
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must([Condition::matches(
|
||||
"color",
|
||||
"red".to_string(),
|
||||
)])),
|
||||
limit: Some(1),
|
||||
with_payload: Some(true.into()),
|
||||
with_vectors: Some(false.into()),
|
||||
..Default::default()
|
||||
})
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}")
|
||||
.filter(Filter::must([Condition::matches(
|
||||
"color",
|
||||
"red".to_string(),
|
||||
)]))
|
||||
.limit(1)
|
||||
.with_payload(true)
|
||||
.with_vectors(false),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1657,18 +1611,14 @@ client.scroll("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, ScrollPoints, OrderBy};
|
||||
use qdrant_client::qdrant::{OrderByBuilder, ScrollPointsBuilder};
|
||||
|
||||
client
|
||||
.scroll(&ScrollPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
limit: Some(15),
|
||||
order_by: Some(OrderBy {
|
||||
key: "timestamp".to_string(), // <-- this!
|
||||
..Default::default(),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.scroll(
|
||||
ScrollPointsBuilder::new("{collection_name}")
|
||||
.limit(15)
|
||||
.order_by(OrderByBuilder::new("timestamp")),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1714,13 +1664,12 @@ order_by: {
|
||||
```
|
||||
|
||||
```rust
|
||||
order_by: Some(OrderBy {
|
||||
key: "timestamp".to_string(),
|
||||
direction: Some(Direction::Desc as i32), // default is Direction::Asc
|
||||
start_from: Some(StartFrom {
|
||||
value: Some(Value::Integer(123)),
|
||||
}),
|
||||
});
|
||||
use qdrant_client::qdrant::{start_from::Value, Direction, OrderByBuilder};
|
||||
|
||||
OrderByBuilder::new("timestamp")
|
||||
.direction(Direction::Desc.into())
|
||||
.start_from(Value::Integer(123))
|
||||
.build();
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -1812,18 +1761,17 @@ client.count("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, CountPoints, Filter};
|
||||
use qdrant_client::qdrant::{Condition, CountPointsBuilder, Filter};
|
||||
|
||||
client
|
||||
.count(&CountPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must([Condition::matches(
|
||||
"color",
|
||||
"red".to_string(),
|
||||
)])),
|
||||
exact: Some(true),
|
||||
..Default::default()
|
||||
})
|
||||
.count(
|
||||
CountPointsBuilder::new("{collection_name}")
|
||||
.filter(Filter::must([Condition::matches(
|
||||
"color",
|
||||
"red".to_string(),
|
||||
)]))
|
||||
.exact(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -2071,122 +2019,86 @@ client.batchUpdate("{collection_name}", {
|
||||
use std::collections::HashMap;
|
||||
|
||||
use qdrant_client::qdrant::{
|
||||
points_selector::PointsSelectorOneOf,
|
||||
points_update_operation::{
|
||||
ClearPayload, DeletePayload, DeletePoints, DeleteVectors, Operation, PointStructList,
|
||||
SetPayload, UpdateVectors,
|
||||
ClearPayload, DeletePayload, DeletePoints, DeleteVectors, Operation, OverwritePayload,
|
||||
PointStructList, SetPayload, UpdateVectors,
|
||||
},
|
||||
PointStruct, PointVectors, PointsIdsList, PointsSelector, PointsUpdateOperation,
|
||||
VectorsSelector,
|
||||
PointStruct, PointVectors, PointsUpdateOperation, UpdateBatchPointsBuilder, VectorsSelector,
|
||||
};
|
||||
use serde_json::json;
|
||||
use qdrant_client::Payload;
|
||||
|
||||
client
|
||||
.batch_updates_blocking(
|
||||
"{collection_name}",
|
||||
&[
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::Upsert(PointStructList {
|
||||
points: vec![PointStruct::new(
|
||||
1,
|
||||
vec![1.0, 2.0, 3.0, 4.0],
|
||||
json!({}).try_into().unwrap(),
|
||||
)],
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::UpdateVectors(UpdateVectors {
|
||||
points: vec![PointVectors {
|
||||
id: Some(1.into()),
|
||||
vectors: Some(vec![1.0, 2.0, 3.0, 4.0].into()),
|
||||
}],
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::DeleteVectors(DeleteVectors {
|
||||
points_selector: Some(PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(
|
||||
PointsIdsList {
|
||||
ids: vec![1.into()],
|
||||
},
|
||||
)),
|
||||
}),
|
||||
vectors: Some(VectorsSelector {
|
||||
names: vec!["".into()],
|
||||
}),
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::OverwritePayload(SetPayload {
|
||||
points_selector: Some(PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(
|
||||
PointsIdsList {
|
||||
ids: vec![1.into()],
|
||||
},
|
||||
)),
|
||||
}),
|
||||
payload: HashMap::from([("test_payload".to_string(), 1.into())]),
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::SetPayload(SetPayload {
|
||||
points_selector: Some(PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(
|
||||
PointsIdsList {
|
||||
ids: vec![1.into()],
|
||||
},
|
||||
)),
|
||||
}),
|
||||
payload: HashMap::from([
|
||||
("test_payload_2".to_string(), 2.into()),
|
||||
("test_payload_3".to_string(), 3.into()),
|
||||
]),
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::DeletePayload(DeletePayload {
|
||||
points_selector: Some(PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(
|
||||
PointsIdsList {
|
||||
ids: vec![1.into()],
|
||||
},
|
||||
)),
|
||||
}),
|
||||
keys: vec!["test_payload_2".to_string()],
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::ClearPayload(ClearPayload {
|
||||
points: Some(PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(
|
||||
PointsIdsList {
|
||||
ids: vec![1.into()],
|
||||
},
|
||||
)),
|
||||
}),
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::DeletePoints(DeletePoints {
|
||||
points: Some(PointsSelector {
|
||||
points_selector_one_of: Some(PointsSelectorOneOf::Points(
|
||||
PointsIdsList {
|
||||
ids: vec![1.into()],
|
||||
},
|
||||
)),
|
||||
}),
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
],
|
||||
None,
|
||||
.update_points_batch(
|
||||
UpdateBatchPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::Upsert(PointStructList {
|
||||
points: vec![PointStruct::new(
|
||||
1,
|
||||
vec![1.0, 2.0, 3.0, 4.0],
|
||||
Payload::default(),
|
||||
)],
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::UpdateVectors(UpdateVectors {
|
||||
points: vec![PointVectors {
|
||||
id: Some(1.into()),
|
||||
vectors: Some(vec![1.0, 2.0, 3.0, 4.0].into()),
|
||||
}],
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::DeleteVectors(DeleteVectors {
|
||||
points_selector: Some(vec![1.into()].into()),
|
||||
vectors: Some(VectorsSelector {
|
||||
names: vec!["".into()],
|
||||
}),
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::OverwritePayload(OverwritePayload {
|
||||
points_selector: Some(vec![1.into()].into()),
|
||||
payload: HashMap::from([("test_payload".to_string(), 1.into())]),
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::SetPayload(SetPayload {
|
||||
points_selector: Some(vec![1.into()].into()),
|
||||
payload: HashMap::from([
|
||||
("test_payload_2".to_string(), 2.into()),
|
||||
("test_payload_3".to_string(), 3.into()),
|
||||
]),
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::DeletePayload(DeletePayload {
|
||||
points_selector: Some(vec![1.into()].into()),
|
||||
keys: vec!["test_payload_2".to_string()],
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::ClearPayload(ClearPayload {
|
||||
points: Some(vec![1.into()].into()),
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
PointsUpdateOperation {
|
||||
operation: Some(Operation::DeletePoints(DeletePoints {
|
||||
points: Some(vec![1.into()].into()),
|
||||
..Default::default()
|
||||
})),
|
||||
},
|
||||
],
|
||||
)
|
||||
.wait(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -275,29 +275,18 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{Condition, Filter, SearchParams, SearchPoints},
|
||||
};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
use qdrant_client::qdrant::{Condition, Filter, SearchParamsBuilder, SearchPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
filter: Some(Filter::must([Condition::matches(
|
||||
"city",
|
||||
"London".to_string(),
|
||||
)])),
|
||||
params: Some(SearchParams {
|
||||
hnsw_ef: Some(128),
|
||||
exact: Some(false),
|
||||
..Default::default()
|
||||
}),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
limit: 3,
|
||||
..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)),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -418,18 +407,16 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{client::QdrantClient, qdrant::SearchPoints};
|
||||
use qdrant_client::qdrant::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],
|
||||
vector_name: Some("image".to_string()),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3)
|
||||
.vector_name("image"),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -535,21 +522,17 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{client::QdrantClient, client::Vector, qdrant::SearchPoints};
|
||||
use qdrant_client::qdrant::SearchPointsBuilder;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let sparse_vector: Vector = vec![(1, 2.0), (7, 1.0)].into();
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector_name: Some("text".to_string()),
|
||||
sparse_indices: sparse_vector.indices,
|
||||
vector: sparse_vector.data,
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![2.0, 1.0], 3)
|
||||
.sparse_indices(vec![1, 7])
|
||||
.vector_name("text"),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -634,19 +617,17 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{client::QdrantClient, qdrant::SearchPoints};
|
||||
use qdrant_client::qdrant::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],
|
||||
with_payload: Some(true.into()),
|
||||
with_vectors: Some(true.into()),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3)
|
||||
.with_payload(true)
|
||||
.with_vectors(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -725,18 +706,22 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{client::QdrantClient, qdrant::SearchPoints};
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
use qdrant_client::qdrant::{with_payload_selector::SelectorOptions, SearchPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
client
|
||||
.search_points(&SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
with_payload: Some(vec!["city", "village", "town"].into()),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3)
|
||||
.with_payload(SelectorOptions::Include(
|
||||
vec![
|
||||
"city".to_string(),
|
||||
"village".to_string(),
|
||||
"town".to_string(),
|
||||
]
|
||||
.into(),
|
||||
))
|
||||
.with_vectors(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -823,28 +808,22 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{
|
||||
with_payload_selector::SelectorOptions, PayloadExcludeSelector, SearchPoints,
|
||||
WithPayloadSelector,
|
||||
},
|
||||
};
|
||||
use qdrant_client::qdrant::{with_payload_selector::SelectorOptions, 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],
|
||||
with_payload: Some(WithPayloadSelector {
|
||||
selector_options: Some(SelectorOptions::Exclude(PayloadExcludeSelector {
|
||||
fields: vec!["city".to_string()],
|
||||
})),
|
||||
}),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3)
|
||||
.with_payload(SelectorOptions::Exclude(
|
||||
vec![
|
||||
"city".to_string(),
|
||||
]
|
||||
.into(),
|
||||
))
|
||||
.with_vectors(true),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1005,39 +984,23 @@ client.searchBatch("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
client::QdrantClient,
|
||||
qdrant::{Condition, Filter, SearchBatchPoints, SearchPoints},
|
||||
};
|
||||
use qdrant_client::qdrant::{Condition, Filter, SearchBatchPointsBuilder, SearchPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let filter = Filter::must([Condition::matches("city", "London".to_string())]);
|
||||
|
||||
let searches = vec![
|
||||
SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector: vec![0.2, 0.1, 0.9, 0.7],
|
||||
filter: Some(filter.clone()),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
},
|
||||
SearchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector: vec![0.5, 0.3, 0.2, 0.3],
|
||||
filter: Some(filter),
|
||||
limit: 3,
|
||||
..Default::default()
|
||||
},
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3)
|
||||
.filter(filter.clone())
|
||||
.build(),
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.5, 0.3, 0.2, 0.3], 3)
|
||||
.filter(filter.)
|
||||
.build(),
|
||||
];
|
||||
|
||||
client
|
||||
.search_batch_points(&SearchBatchPoints {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
search_points: searches,
|
||||
read_consistency: None,
|
||||
..Default::default()
|
||||
})
|
||||
.search_batch_points(SearchBatchPointsBuilder::new("{collection_name}", searches))
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1168,20 +1131,19 @@ client.search("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{client::QdrantClient, qdrant::SearchPoints};
|
||||
use qdrant_client::qdrant::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],
|
||||
with_vectors: Some(true.into()),
|
||||
with_payload: Some(true.into()),
|
||||
limit: 10,
|
||||
offset: Some(100),
|
||||
..Default::default()
|
||||
})
|
||||
.search_points(
|
||||
SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3)
|
||||
.with_payload(true)
|
||||
.with_vectors(true)
|
||||
.limit(10)
|
||||
.offset(100),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1341,17 +1303,16 @@ client.searchPointGroups("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::SearchPointGroups;
|
||||
use qdrant_client::qdrant::SearchPointGroupsBuilder;
|
||||
|
||||
client
|
||||
.search_groups(&SearchPointGroups {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector: vec![1.1],
|
||||
group_by: "document_id".to_string(),
|
||||
limit: 4,
|
||||
group_size: 2,
|
||||
..Default::default()
|
||||
})
|
||||
.search_groups(SearchPointGroupsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![1.1],
|
||||
4,
|
||||
"document_id",
|
||||
2,
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -1517,22 +1478,21 @@ client.searchPointGroups("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{SearchPointGroups, WithLookup};
|
||||
use qdrant_client::qdrant::{
|
||||
with_payload_selector::SelectorOptions, SearchPointGroupsBuilder, WithLookupBuilder,
|
||||
};
|
||||
|
||||
client
|
||||
.search_groups(&SearchPointGroups {
|
||||
collection_name: "{collection_name}".to_string(),
|
||||
vector: vec![1.1],
|
||||
group_by: "document_id".to_string(),
|
||||
limit: 2,
|
||||
group_size: 2,
|
||||
with_lookup: Some(WithLookup {
|
||||
collection: "documents".to_string(),
|
||||
with_payload: Some(vec!["title", "text"].into()),
|
||||
with_vectors: Some(false.into()),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.search_groups(
|
||||
SearchPointGroupsBuilder::new("{collection_name}", vec![1.1], 2, "document_id", 2)
|
||||
.with_lookup(
|
||||
WithLookupBuilder::new("documents")
|
||||
.with_payload(SelectorOptions::Include(
|
||||
vec!["title".to_string(), "text".to_string()].into(),
|
||||
))
|
||||
.with_vectors(false),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ client.createSnapshot("{collection_name}");
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client.create_snapshot("{collection_name}").await?;
|
||||
```
|
||||
@@ -96,11 +96,17 @@ client.deleteSnapshot("{collection_name}", "{snapshot_name}");
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::qdrant::DeleteSnapshotRequestBuilder;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client.delete_snapshot("{collection_name}", "{snapshot_name}").await?;
|
||||
client
|
||||
.delete_snapshot(DeleteSnapshotRequestBuilder::new(
|
||||
"{collection_name}",
|
||||
"{snapshot_name}",
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -146,9 +152,9 @@ client.listSnapshots("{collection_name}");
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client.list_snapshots("{collection_name}").await?;
|
||||
```
|
||||
@@ -364,9 +370,9 @@ client.createFullSnapshot();
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client.create_full_snapshot().await?;
|
||||
```
|
||||
@@ -414,9 +420,9 @@ client.deleteFullSnapshot("{snapshot_name}");
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client.delete_full_snapshot("{snapshot_name}").await?;
|
||||
```
|
||||
@@ -462,9 +468,9 @@ client.listFullSnapshots();
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::client::QdrantClient;
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = QdrantClient::from_url("http://localhost:6334").build()?;
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client.list_full_snapshots().await?;
|
||||
```
|
||||
|
||||
@@ -81,26 +81,16 @@ 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}".to_string(),
|
||||
vectors_config: Some(VectorsConfig {
|
||||
config: Some(Config::Params(VectorParams {
|
||||
size: 768,
|
||||
distance: Distance::Cosine.into(),
|
||||
on_disk: Some(true),
|
||||
..Default::default()
|
||||
})),
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine).on_disk(true)),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -194,32 +184,19 @@ 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 {
|
||||
memmap_threshold: Some(20000),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(768, Distance::Cosine))
|
||||
.optimizers_config(OptimizersConfigDiffBuilder::default().memmap_threshold(20000)),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
@@ -323,36 +300,21 @@ 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, 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 {
|
||||
memmap_threshold: Some(20000),
|
||||
..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))
|
||||
.optimizers_config(OptimizersConfigDiffBuilder::default().memmap_threshold(20000))
|
||||
.hnsw_config(HnswConfigDiffBuilder::default().on_disk(true)),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
|
||||
@@ -127,29 +127,22 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::{
|
||||
Qdrant,
|
||||
qdrant::{
|
||||
CreateCollectionBuilder,
|
||||
SparseVectorsConfigBuilder,
|
||||
SparseVectorParamsBuilder,
|
||||
},
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, SparseVectorParamsBuilder, SparseVectorsConfigBuilder,
|
||||
};
|
||||
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let mut sparse_vectors_config = SparseVectorsConfigBuilder::default();
|
||||
|
||||
sparse_vectors_config.add_named_vector_params(
|
||||
"text",
|
||||
SparseVectorParamsBuilder::default()
|
||||
);
|
||||
sparse_vectors_config.add_named_vector_params("text", SparseVectorParamsBuilder::default());
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new(collection_name)
|
||||
.sparse_vectors_config(sparse_vectors_config)
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.sparse_vectors_config(sparse_vectors_config),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -248,35 +241,24 @@ client.upsert("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
PointStruct,
|
||||
UpsertPointsBuilder,
|
||||
NamedVectors,
|
||||
Vector,
|
||||
};
|
||||
use qdrant_client::{Qdrant, Payload};
|
||||
use qdrant_client::qdrant::{NamedVectors, PointStruct, UpsertPointsBuilder, Vector};
|
||||
|
||||
use qdrant_client::{Payload, Qdrant};
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let points = vec![
|
||||
PointStruct::new(
|
||||
129,
|
||||
NamedVectors::default().add_vector(
|
||||
"text",
|
||||
Vector::new_sparse(
|
||||
vec![1, 3, 5, 7],
|
||||
vec![0.1, 0.2, 0.3, 0.4]
|
||||
)
|
||||
),
|
||||
Payload::new()
|
||||
)
|
||||
];
|
||||
let points = vec![PointStruct::new(
|
||||
129,
|
||||
NamedVectors::default().add_vector(
|
||||
"text",
|
||||
Vector::new_sparse(vec![1, 3, 5, 7], vec![0.1, 0.2, 0.3, 0.4]),
|
||||
),
|
||||
Payload::new(),
|
||||
)];
|
||||
|
||||
client
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new("{collection_name}", points)
|
||||
).await?;
|
||||
.upsert_points(UpsertPointsBuilder::new("{collection_name}", points))
|
||||
.await?;
|
||||
```
|
||||
|
||||
```java
|
||||
@@ -879,28 +861,19 @@ client.createCollection("{collection_name}", {
|
||||
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
VectorsConfigBuilder,
|
||||
Distance,
|
||||
VectorParamsBuilder
|
||||
CreateCollectionBuilder, Distance, VectorParamsBuilder, VectorsConfigBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let mut vector_config = VectorsConfigBuilder::default();
|
||||
|
||||
vector_config.add_named_vector_params(
|
||||
"text",
|
||||
VectorParamsBuilder::new(4, Distance::Dot),
|
||||
);
|
||||
vector_config.add_named_vector_params(
|
||||
"image",
|
||||
VectorParamsBuilder::new(8, Distance::Cosine),
|
||||
);
|
||||
vector_config.add_named_vector_params("text", VectorParamsBuilder::new(4, Distance::Dot));
|
||||
vector_config.add_named_vector_params("image", VectorParamsBuilder::new(8, Distance::Cosine));
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(vector_config)
|
||||
CreateCollectionBuilder::new("{collection_name}").vectors_config(vector_config),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
@@ -1049,30 +1022,24 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder,
|
||||
Distance,
|
||||
SparseIndexConfigBuilder,
|
||||
SparseVectorParamsBuilder,
|
||||
VectorParamsBuilder,
|
||||
Datatype,
|
||||
CreateCollectionBuilder, Datatype, Distance, SparseIndexConfigBuilder, SparseVectorParamsBuilder, SparseVectorsConfigBuilder, VectorParamsBuilder
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let mut sparse_vector_config = SparseVectorsConfigBuilder::default();
|
||||
|
||||
sparse_vector_config.add_named_vector_params(
|
||||
"text",
|
||||
SparseVectorParamsBuilder::default()
|
||||
.index(SparseIndexConfigBuilder::default().datatype(Datatype::Float32)),
|
||||
);
|
||||
let create_collection = CreateCollectionBuilder::new(collection_name)
|
||||
|
||||
let create_collection = CreateCollectionBuilder::new("{collection_name}")
|
||||
.sparse_vectors_config(sparse_vector_config)
|
||||
.vectors_config(
|
||||
VectorParamsBuilder::new(128, Distance::Cosine)
|
||||
.datatype(Datatype::Float16)
|
||||
VectorParamsBuilder::new(128, Distance::Cosine).datatype(Datatype::Float16),
|
||||
);
|
||||
|
||||
client.create_collection(create_collection).await?;
|
||||
@@ -1220,16 +1187,13 @@ client.createCollection("{collection_name}", {
|
||||
```
|
||||
|
||||
```rust
|
||||
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder,
|
||||
Distance,
|
||||
SparseIndexConfigBuilder,
|
||||
SparseVectorParamsBuilder,
|
||||
VectorParamsBuilder,
|
||||
Datatype,
|
||||
CreateCollectionBuilder, Datatype, Distance, SparseIndexConfigBuilder,
|
||||
SparseVectorParamsBuilder, SparseVectorsConfigBuilder, VectorParamsBuilder,
|
||||
};
|
||||
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
let mut sparse_vector_config = SparseVectorsConfigBuilder::default();
|
||||
@@ -1239,7 +1203,7 @@ sparse_vector_config.add_named_vector_params(
|
||||
SparseVectorParamsBuilder::default()
|
||||
.index(SparseIndexConfigBuilder::default().datatype(Datatype::Uint8)),
|
||||
);
|
||||
let create_collection = CreateCollectionBuilder::new(collection_name)
|
||||
let create_collection = CreateCollectionBuilder::new("{collection_name}")
|
||||
.sparse_vectors_config(sparse_vector_config)
|
||||
.vectors_config(
|
||||
VectorParamsBuilder::new(128, Distance::Cosine)
|
||||
|
||||
Reference in New Issue
Block a user