Skip to main content

Qdrant

Struct Qdrant 

Source
pub struct Qdrant {
    pub config: QdrantConfig,
    /* private fields */
}
Expand description

API client to interact with a Qdrant server.

Connects to a Qdrant server and provides an API interface.

§Set up

Set up a Qdrant client to connect to a Qdrant instance with just an URL:

use qdrant_client::Qdrant;

let client = Qdrant::from_url("http://localhost:6334").build()?;

Or use an URL, API key and timeout:

use qdrant_client::Qdrant;

let client = Qdrant::from_url("http://localhost:6334")
    .api_key(std::env::var("QDRANT_API_KEY"))
    .timeout(std::time::Duration::from_secs(10))
    .build()?;

§Operations

Categories:

Common operations include:

Fields§

§config: QdrantConfig

Client configuration

Implementations§

Source§

impl Qdrant

§Collection operations

Create, update and delete collections, manage collection aliases and collection cluster configuration.

Source

pub async fn create_collection( &self, request: impl Into<CreateCollection>, ) -> Result<CollectionOperationResponse, QdrantError>

Create a new collection.

use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};

client
    .create_collection(
        CreateCollectionBuilder::new("my_collection")
            .vectors_config(VectorParamsBuilder::new(100, Distance::Cosine)),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/collections/#create-a-collection

Source

pub async fn collection_info( &self, request: impl Into<GetCollectionInfoRequest>, ) -> Result<GetCollectionInfoResponse, QdrantError>

Get collection info.

client.collection_info("my_collection").await?;

Documentation: https://qdrant.tech/documentation/concepts/collections/#collection-info

Source

pub async fn list_collections( &self, ) -> Result<ListCollectionsResponse, QdrantError>

List all collections.

client.list_collections().await?;

This only lists collection names. To list collection name aliases, use list_aliases.

Documentation: https://qdrant.tech/documentation/concepts/collections/#list-all-collections

Source

pub async fn collection_exists( &self, request: impl Into<CollectionExistsRequest>, ) -> Result<bool, QdrantError>

Check whether a collection exists.

client.collection_exists("my_collection").await?;

Documentation: https://qdrant.tech/documentation/concepts/collections/#check-collection-existence

Source

pub async fn update_collection( &self, request: impl Into<UpdateCollection>, ) -> Result<CollectionOperationResponse, QdrantError>

Update collection.

Change parameters of a collection, such as the indexing threshold, for a collection that has already been created.

use qdrant_client::qdrant::{OptimizersConfigDiffBuilder, UpdateCollectionBuilder};

client
    .update_collection(
        UpdateCollectionBuilder::new("my_collection").optimizers_config(
            OptimizersConfigDiffBuilder::default().indexing_threshold(10_000),
        ),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/collections/#update-collection-parameters

Source

pub async fn delete_collection( &self, request: impl Into<DeleteCollection>, ) -> Result<CollectionOperationResponse, QdrantError>

Delete an existing collection.

client.delete_collection("my_collection").await?;

Documentation: https://qdrant.tech/documentation/concepts/collections/#delete-collection

Source

pub async fn create_alias( &self, request: impl Into<CreateAlias>, ) -> Result<CollectionOperationResponse, QdrantError>

Create new collection name alias.

use qdrant_client::qdrant::CreateAliasBuilder;

client
    .create_alias(CreateAliasBuilder::new("my_collection", "my_alias"))
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/collections/#create-alias

Source

pub async fn list_aliases(&self) -> Result<ListAliasesResponse, QdrantError>

List collection name aliases for all collections.

client.list_aliases().await?;

This only lists collection name aliases. To list collection names, use list_collections.

Documentation: https://qdrant.tech/documentation/concepts/collections/#list-all-aliases

Source

pub async fn list_collection_aliases( &self, request: impl Into<ListCollectionAliasesRequest>, ) -> Result<ListAliasesResponse, QdrantError>

List collection name aliases for a specific collection.

client.list_collection_aliases("my_collection").await?;

Documentation: https://qdrant.tech/documentation/concepts/collections/#list-collection-aliases

Source

pub async fn rename_alias( &self, request: impl Into<RenameAlias>, ) -> Result<CollectionOperationResponse, QdrantError>

Rename existing collection name alias.

use qdrant_client::qdrant::RenameAliasBuilder;

client
    .rename_alias(RenameAliasBuilder::new("old_alias", "new_alias"))
    .await?;
Source

pub async fn delete_alias( &self, request: impl Into<DeleteAlias>, ) -> Result<CollectionOperationResponse, QdrantError>

Delete existing collection name alias.

use qdrant_client::qdrant::CreateAliasBuilder;

client
    .delete_alias("my_alias")
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/collections/#remove-alias

Source

pub async fn collection_cluster_info( &self, request: impl Into<CollectionClusterInfoRequest>, ) -> Result<CollectionClusterInfoResponse, QdrantError>

List cluster info of a collection.

client.collection_cluster_info("my_collection").await?;

Documentation: https://qdrant.tech/documentation/concepts/collections/#collection-info

Source

pub async fn update_collection_cluster_setup( &self, request: impl Into<UpdateCollectionClusterSetupRequest>, ) -> Result<UpdateCollectionClusterSetupResponse, QdrantError>

Update collection cluster setup.

Perform a collection cluster Operation, such as MoveShard, ReplicateShard or CreateShardKey.

use qdrant_client::qdrant::{MoveShardBuilder, UpdateCollectionClusterSetupRequestBuilder};

client
    .update_collection_cluster_setup(UpdateCollectionClusterSetupRequestBuilder::new(
        "my_collection",
        MoveShardBuilder::new(
            0, // Shard ID
            0, // From peer ID
            1, // To peer ID
        ),
    ))
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/collections/#create-a-collection

Source§

impl Qdrant

§Index operations

Manage field and payload indices in collections.

Source

pub async fn create_field_index( &self, request: impl Into<CreateFieldIndexCollection>, ) -> Result<PointsOperationResponse, QdrantError>

Create payload index in a collection.

use qdrant_client::qdrant::{CreateFieldIndexCollectionBuilder, FieldType};

client
    .create_field_index(
        CreateFieldIndexCollectionBuilder::new(
            "my_collection",
            "city",
            FieldType::Keyword,
        ),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/indexing/#payload-index

Source

pub async fn delete_field_index( &self, request: impl Into<DeleteFieldIndexCollection>, ) -> Result<PointsOperationResponse, QdrantError>

Delete payload index from a collection.

use qdrant_client::qdrant::DeleteFieldIndexCollectionBuilder;

client
    .delete_field_index(DeleteFieldIndexCollectionBuilder::new(
        "my_collection",
        "city",
    ))
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/indexing/#payload-index

Source§

impl Qdrant

§Payload operations

Manage point payloads.

Source

pub async fn set_payload( &self, request: impl Into<SetPayloadPoints>, ) -> Result<PointsOperationResponse, QdrantError>

Set payload of points.

Sets only the given payload values on a point, leaving other existing payloads in place.

use qdrant_client::Payload;
use qdrant_client::qdrant::{PointsIdsList, SetPayloadPointsBuilder};
use serde_json::json;

let payload: Payload = json!({
    "property1": "string",
    "property2": "string",
})
.try_into()
.unwrap();

client
    .set_payload(
        SetPayloadPointsBuilder::new("my_collection", payload)
            .points_selector(PointsIdsList {
                ids: vec![0.into(), 3.into(), 10.into()],
            })
            .wait(true),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/payload/#set-payload

Source

pub async fn overwrite_payload( &self, request: impl Into<SetPayloadPoints>, ) -> Result<PointsOperationResponse, QdrantError>

Overwrite payload of points.

Sets the given payload values on a point, completely replacing existing payload.

use qdrant_client::Payload;
use qdrant_client::qdrant::{
    points_selector::PointsSelectorOneOf, PointsIdsList, SetPayloadPointsBuilder,
};
use serde_json::json;

let payload: Payload = json!({
    "property1": "string",
    "property2": "string",
})
.try_into()
.unwrap();

client
    .overwrite_payload(
        SetPayloadPointsBuilder::new("my_collection", payload)
            .points_selector(PointsSelectorOneOf::Points(PointsIdsList {
                ids: vec![0.into(), 3.into(), 10.into()],
            }))
            .wait(true),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/payload/#overwrite-payload

Source

pub async fn delete_payload( &self, request: impl Into<DeletePayloadPoints>, ) -> Result<PointsOperationResponse, QdrantError>

Delete specified payload keys of points.

use qdrant_client::qdrant::{DeletePayloadPointsBuilder, PointsIdsList};

client
    .delete_payload(
        DeletePayloadPointsBuilder::new(
            "my_collection",
            vec!["color".to_string(), "price".to_string()],
        )
        .points_selector(PointsIdsList {
            ids: vec![0.into(), 3.into(), 100.into()],
        })
        .wait(true),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/payload/#delete-payload-keys

Source

pub async fn clear_payload( &self, request: impl Into<ClearPayloadPoints>, ) -> Result<PointsOperationResponse, QdrantError>

Clear all payload of points.

use qdrant_client::qdrant::{ClearPayloadPointsBuilder, PointsIdsList};

client
    .clear_payload(ClearPayloadPointsBuilder::new("my_collection").points(
        PointsIdsList {
            ids: vec![0.into(), 3.into(), 100.into()],
        },
    ))
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/payload/#clear-payload

Source§

impl Qdrant

§Point operations

Manage points and vectors.

Source

pub async fn upsert_points( &self, request: impl Into<UpsertPoints>, ) -> Result<PointsOperationResponse, QdrantError>

Insert or update points in a collection.

If points with the specified IDs already exist, they will be overwritten.

All points are upserted in a single operation. For a large number of points you likley want split all upsertions into separate operations to avoid timing out. You can use upsert_points_chunked to automatically do that for you.

use qdrant_client::Payload;
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
use serde_json::json;

client
    .upsert_points(
        UpsertPointsBuilder::new(
            "my_collection",
            vec![
                PointStruct::new(
                    1,
                    vec![0.9, 0.1, 0.1],
                    Payload::try_from(json!(
                        {"color": "red"}
                    ))
                    .unwrap(),
                ),
                PointStruct::new(
                    2,
                    vec![0.1, 0.9, 0.1],
                    Payload::try_from(json!(
                        {"color": "green"}
                    ))
                    .unwrap(),
                ),
                PointStruct::new(
                    3,
                    vec![0.1, 0.1, 0.9],
                    Payload::try_from(json!(
                        {"color": "blue"}
                    ))
                    .unwrap(),
                ),
            ],
        )
        .wait(true),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/points/#upload-points

Source

pub async fn upsert_points_chunked( &self, request: impl Into<UpsertPoints>, chunk_size: usize, ) -> Result<PointsOperationResponse, QdrantError>

Insert or update points in a collection.

The same as upsert_points, but it automatically splits all points into chunks of chunk_size to prevent timing out.

Source

pub async fn get_points( &self, request: impl Into<GetPoints>, ) -> Result<GetResponse, QdrantError>

Retrieve specific points from a collection.

Use with_vectors and with_payload to specify whether to include or exclude vector and payload data in the response. By default they are excluded to save bandwidth.

use qdrant_client::qdrant::GetPointsBuilder;

client
    .get_points(
        GetPointsBuilder::new(
            "my_collection",
            vec![0.into(), 30.into(), 100.into()],
        )
        .with_vectors(true)
        .with_payload(true)
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/points/#retrieve-points

Source

pub async fn scroll( &self, request: impl Into<ScrollPoints>, ) -> Result<ScrollResponse, QdrantError>

Scroll points in a collection.

Use with_vectors and with_payload to specify whether to include or exclude vector and payload data in the response. By default they are excluded to save bandwidth.

use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder};

client
    .scroll(
        ScrollPointsBuilder::new("my_collection")
            .filter(Filter::must([Condition::matches(
                "color",
                "red".to_string(),
            )]))
            .limit(1)
            .with_payload(true)
            .with_vectors(true),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/points/#scroll-points

Source

pub async fn count( &self, request: impl Into<CountPoints>, ) -> Result<CountResponse, QdrantError>

Count points in a collection.

Use exact to specify whether to use exact counting. Exact counting is more accurate but slower.

use qdrant_client::qdrant::{Condition, CountPointsBuilder, Filter};

client
    .count(
        CountPointsBuilder::new("collection_name")
            .filter(Filter::must([Condition::matches(
                "color",
                "red".to_string(),
            )]))
            .exact(true),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/points/#counting-points

Source

pub async fn update_points_batch( &self, request: impl Into<UpdateBatchPoints>, ) -> Result<UpdateBatchResponse, QdrantError>

Batch point operations in a collection.

Perform a batch of point Operations in a single request.

use qdrant_client::Payload;
use qdrant_client::qdrant::{
    points_selector::PointsSelectorOneOf,
    points_update_operation::{
        Operation, OverwritePayload, PointStructList, UpdateVectors,
    },
    PointStruct, PointVectors, PointsIdsList, PointsSelector, PointsUpdateOperation,
    UpdateBatchPointsBuilder,
};
use serde_json::json;

client
    .update_points_batch(
        UpdateBatchPointsBuilder::new(
            "my_collection",
            vec![
                PointsUpdateOperation {
                    operation: Some(Operation::Upsert(PointStructList {
                        points: vec![PointStruct::new(
                            1,
                            vec![1.0, 2.0, 3.0, 4.0],
                            Payload::try_from(json!({})).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::OverwritePayload(OverwritePayload {
                        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()
                    })),
                },
            ],
        )
        .wait(true),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/points/#batch-update

Source

pub async fn delete_points( &self, request: impl Into<DeletePoints>, ) -> Result<PointsOperationResponse, QdrantError>

Delete points from a collection.

Delete by point ID:

use qdrant_client::qdrant::{DeletePointsBuilder, PointsIdsList};

client
    .delete_points(
        DeletePointsBuilder::new("my_collection")
            .points(PointsIdsList {
                ids: vec![0.into(), 3.into(), 100.into()],
            })
            .wait(true),
    )
    .await?;

Or delete by Filter:

use qdrant_client::qdrant::{Condition, DeletePointsBuilder, Filter};

client
    .delete_points(
        DeletePointsBuilder::new("my_collection")
            .points(Filter::must([Condition::matches(
                "color",
                "red".to_string(),
            )]))
            .wait(true),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/points/#delete-points

Source

pub async fn update_vectors( &self, request: impl Into<UpdatePointVectors>, ) -> Result<PointsOperationResponse, QdrantError>

Update vectors on points.

Updates the given vectors on points in a collection, leaving existing vectors on these points with a different name in place.

use qdrant_client::qdrant::{PointVectors, UpdatePointVectorsBuilder};

client
    .update_vectors(
        UpdatePointVectorsBuilder::new(
            "my_collection",
            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?;

Documentation: https://qdrant.tech/documentation/concepts/points/#update-vectors

Source

pub async fn delete_vectors( &self, request: impl Into<DeletePointVectors>, ) -> Result<PointsOperationResponse, QdrantError>

Delete vectors from points.

Removes specified vectors from points in a collection, leaving existing vectors on these points with a different name in place.

use qdrant_client::qdrant::{DeletePointVectorsBuilder, PointsIdsList, VectorsSelector};

client
    .delete_vectors(
        DeletePointVectorsBuilder::new("my_collection")
            .points_selector(PointsIdsList {
                ids: vec![0.into(), 3.into(), 10.into()],
            })
            .vectors(VectorsSelector {
                names: vec!["text".into(), "image".into()],
            })
            .wait(true),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/points/#delete-vectors

Source

pub async fn facet( &self, request: impl Into<FacetCounts>, ) -> Result<FacetResponse, QdrantError>

Get the amount of records for each unique value of a field.

use qdrant_client::qdrant::{Condition, FacetCountsBuilder, Filter};

let ten_countries_with_most_points_in_europe = client
   .facet(
        FacetCountsBuilder::new("world_data", "country")
            .limit(10)
            .filter(Filter::must(vec![Condition::matches(
                "continent",
                "Europe".to_string(),
            )])),
    )
    .await
    .unwrap();
Source

pub async fn search_matrix_pairs( &self, request: impl Into<SearchMatrixPoints>, ) -> Result<SearchMatrixPairsResponse, QdrantError>

Get a (sparse) matrix of points with closest distance, returned as pairs.

use qdrant_client::qdrant::{Condition, SearchMatrixPointsBuilder, Filter};

let matrix = client
    .search_matrix_pairs(
        SearchMatrixPointsBuilder::new("collection_name")
            .filter(Filter::must(vec![Condition::matches(
                "color",
                "red".to_string(),
            )]))
            .sample(1000)
            .limit(10),
    )
    .await?;
Source

pub async fn search_matrix_offsets( &self, request: impl Into<SearchMatrixPoints>, ) -> Result<SearchMatrixOffsetsResponse, QdrantError>

Get a (sparse) matrix of points with closest distance.

use qdrant_client::qdrant::{Condition, SearchMatrixPointsBuilder, Filter};

let matrix = client
    .search_matrix_offsets(
        SearchMatrixPointsBuilder::new("collection_name")
            .filter(Filter::must(vec![Condition::matches(
                "color",
                "red".to_string(),
            )]))
            .sample(1000)
            .limit(10),
    )
    .await?;
Source§

impl Qdrant

§Query operations

Query points using the universal search API.

Source

pub async fn query( &self, request: impl Into<QueryPoints>, ) -> Result<QueryResponse, QdrantError>

Query points in a collection.

use qdrant_client::qdrant::{Condition, Filter, QueryPointsBuilder};

client
    .query(
        QueryPointsBuilder::new("my_collection")
            .filter(Filter::must([Condition::matches(
                "city",
                "London".to_string(),
            )]))
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/search/#query-api

Source

pub async fn query_batch( &self, request: impl Into<QueryBatchPoints>, ) -> Result<QueryBatchResponse, QdrantError>

Batch multiple point queries in a collection.

use qdrant_client::qdrant::{Condition, Filter, QueryPointsBuilder, QueryBatchPointsBuilder};

client
    .query_batch(
        QueryBatchPointsBuilder::new("my_collection", vec![
            QueryPointsBuilder::new("my_collection")
                .filter(Filter::must([Condition::matches(
                    "city",
                    "London".to_string(),
                )]))
                .build(),
            QueryPointsBuilder::new("my_collection")
                .filter(Filter::must([Condition::matches(
                    "city",
                    "Berlin".to_string(),
                )]))
                .build(),
        ])
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/search/#query-api

Source

pub async fn query_groups( &self, request: impl Into<QueryPointGroups>, ) -> Result<QueryGroupsResponse, QdrantError>

Query points in a collection and group results by a payload field.

use qdrant_client::qdrant::{PrefetchQueryBuilder, QueryPointGroupsBuilder};

client
    .query_groups(
        QueryPointGroupsBuilder::new(
            "my_collection", // Collection name
            "city",          // Group by field
         )
         .add_prefetch(
             PrefetchQueryBuilder::default()
                 .query(vec![0.01, 0.45, 0.67])
                 .limit(100u64)
         )
         .query(vec![0.1, 0.2, 0.3, 0.4]) // Query vector
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/search/#query-api

Source§

impl Qdrant

§Search operations

For searching, please switch to the more fully featured Query API instead. The search API will be removed in the future.

Search and explore points.

Documentation: https://qdrant.tech/documentation/concepts/search/

Source

pub async fn search_points( &self, request: impl Into<SearchPoints>, ) -> Result<SearchResponse, QdrantError>

Search points in a collection.

use qdrant_client::qdrant::{Condition, Filter, SearchParamsBuilder, SearchPointsBuilder};

client
    .search_points(
        SearchPointsBuilder::new("my_collection", 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?;

Documentation: https://qdrant.tech/documentation/concepts/search/#search-api

Source

pub async fn search_batch_points( &self, request: impl Into<SearchBatchPoints>, ) -> Result<SearchBatchResponse, QdrantError>

Batch multiple points searches in a collection.

use qdrant_client::qdrant::{Condition, Filter, SearchBatchPointsBuilder, SearchPointsBuilder,};

let filter = Filter::must([Condition::matches("city", "London".to_string())]);

let searches = vec![
    SearchPointsBuilder::new("my_collection", vec![0.2, 0.1, 0.9, 0.7], 3)
        .filter(filter.clone())
        .build(),
    SearchPointsBuilder::new("my_collection", vec![0.5, 0.3, 0.2, 0.3], 3)
        .filter(filter)
        .build(),
];

client
    .search_batch_points(SearchBatchPointsBuilder::new("my_collection", searches))
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/search/#batch-search-api

Source

pub async fn search_groups( &self, request: impl Into<SearchPointGroups>, ) -> Result<SearchGroupsResponse, QdrantError>

Search points in a collection and group results by a payload field.

use qdrant_client::qdrant::SearchPointGroupsBuilder;

client
    .search_groups(SearchPointGroupsBuilder::new(
        "my_collection", // Collection name
        vec![1.1],       // Search vector
        4,               // Search limit
        "document_id",   // Group by field
        2,               // Group size
    ))
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/search/#search-groups

Source

pub async fn recommend( &self, request: impl Into<RecommendPoints>, ) -> Result<RecommendResponse, QdrantError>

Recommend points in a collection.

use qdrant_client::qdrant::{Condition, Filter, RecommendPointsBuilder, RecommendStrategy};

client
    .recommend(
        RecommendPointsBuilder::new("my_collection", 3)
            .add_positive(100)
            .add_positive(200)
            .add_positive(vec![100.0, 231.0])
            .add_negative(718)
            .add_negative(vec![0.2, 0.3, 0.4, 0.5])
            .strategy(RecommendStrategy::AverageVector)
            .filter(Filter::must([Condition::matches(
                "city",
                "London".to_string(),
            )])),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/explore/#recommendation-api

Source

pub async fn recommend_batch( &self, request: impl Into<RecommendBatchPoints>, ) -> Result<RecommendBatchResponse, QdrantError>

Batch multiple points recommendations in a collection.

use qdrant_client::qdrant::{Condition, Filter, RecommendBatchPointsBuilder, RecommendPointsBuilder};

let filter = Filter::must([Condition::matches("city", "London".to_string())]);

let recommend_queries = vec![
    RecommendPointsBuilder::new("my_collection", 3)
        .add_positive(100)
        .add_positive(231)
        .add_negative(718)
        .filter(filter.clone())
        .build(),
    RecommendPointsBuilder::new("my_collection", 3)
        .add_positive(200)
        .add_positive(67)
        .add_negative(300)
        .filter(filter.clone())
        .build(),
];

client
    .recommend_batch(RecommendBatchPointsBuilder::new(
        "my_collection",
        recommend_queries,
    ))
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/explore/#batch-recommendation-api

Source

pub async fn recommend_groups( &self, request: impl Into<RecommendPointGroups>, ) -> Result<RecommendGroupsResponse, QdrantError>

Recommend points in a collection and group results by a payload field.

use qdrant_client::qdrant::{RecommendPointGroupsBuilder, RecommendStrategy};

client
    .recommend_groups(
        RecommendPointGroupsBuilder::new(
            "my_collection", // Collection name
            "document_id",   // Group by field
            2,               // Group size
            3,               // Search limit
        )
        .add_positive(100)
        .add_positive(200)
        .add_negative(718)
        .strategy(RecommendStrategy::AverageVector),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/explore/#recommendation-api

Source

pub async fn discover( &self, request: impl Into<DiscoverPoints>, ) -> Result<DiscoverResponse, QdrantError>

Discover points in a collection.

use qdrant_client::qdrant::{
    target_vector::Target, vector_example::Example, ContextExamplePairBuilder,
    DiscoverPointsBuilder, VectorExample,
};

client
    .discover(
        DiscoverPointsBuilder::new(
            "my_collection", // 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,              // Search limit
        )
        .target(Target::Single(VectorExample {
            example: Some(Example::Vector(vec![0.2, 0.1, 0.9, 0.7].into())),
        })),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/explore/#discovery-api

Source

pub async fn discover_batch( &self, request: &DiscoverBatchPoints, ) -> Result<DiscoverBatchResponse, QdrantError>

Batch multiple point discoveries in a collection.

use qdrant_client::qdrant::{
    vector_example::Example, ContextExamplePairBuilder, DiscoverBatchPointsBuilder,
    DiscoverPointsBuilder,
};

let discover_points = DiscoverBatchPointsBuilder::new(
    "my_collection",
    vec![
        DiscoverPointsBuilder::new(
            "my_collection",
            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,
        )
        .build(),
        DiscoverPointsBuilder::new(
            "my_collection",
            vec![
                ContextExamplePairBuilder::default()
                    .positive(Example::Id(342.into()))
                    .negative(Example::Id(213.into()))
                    .build(),
                ContextExamplePairBuilder::default()
                    .positive(Example::Id(100.into()))
                    .negative(Example::Id(200.into()))
                    .build(),
            ],
            10,
        )
        .build(),
    ],
);

client.discover_batch(&discover_points.build()).await?;

Documentation: https://qdrant.tech/documentation/concepts/explore/#discovery-api

Source§

impl Qdrant

§Sharding key operations

Create or delete shard keys for collections.

Source

pub async fn create_shard_key( &self, request: impl Into<CreateShardKeyRequest>, ) -> Result<CreateShardKeyResponse, QdrantError>

Create new shard key in a collection.

use qdrant_client::qdrant::shard_key::Key;
use qdrant_client::qdrant::{CreateShardKeyBuilder, CreateShardKeyRequestBuilder};

client
    .create_shard_key(
        CreateShardKeyRequestBuilder::new("my_collection").request(
            CreateShardKeyBuilder::default()
                .shard_key(Key::Keyword("my_key".to_string())),
        ),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/guides/distributed_deployment/#user-defined-sharding

Source

pub async fn list_shard_keys( &self, request: impl Into<ListShardKeysRequest>, ) -> Result<ListShardKeysResponse, QdrantError>

List all shard keys in a collection.

let response = client.list_shard_keys("my_collection").await?;

Documentation: https://qdrant.tech/documentation/guides/distributed_deployment/#user-defined-sharding

Source

pub async fn delete_shard_key( &self, request: impl Into<DeleteShardKeyRequest>, ) -> Result<DeleteShardKeyResponse, QdrantError>

Delete existing shard key from a collection.

Deleting a shard key destroys all shards and data placed in it.

use qdrant_client::qdrant::shard_key::Key;
use qdrant_client::qdrant::DeleteShardKeyRequestBuilder;

client
    .delete_shard_key(
        DeleteShardKeyRequestBuilder::new("my_collection")
            .key(Key::Keyword("my_key".to_string())),
    )
    .await?;

Documentation: https://qdrant.tech/documentation/guides/distributed_deployment/#user-defined-sharding

Source§

impl Qdrant

§Snapshot operations

Create, recover and manage snapshots for collections or a full Qdrant instance.

Source

pub async fn create_snapshot( &self, request: impl Into<CreateSnapshotRequest>, ) -> Result<CreateSnapshotResponse, QdrantError>

Create snapshot of a collection on this node.

client.create_snapshot("my_collection").await?;

Note: Snapshots are node-local. They only contain data of a single node. In distributed mode you must create a snapshot on each node separately. Each node has their own list of snapshots.

Documentation: https://qdrant.tech/documentation/concepts/snapshots/#create-snapshot

Source

pub async fn list_snapshots( &self, request: impl Into<ListSnapshotsRequest>, ) -> Result<ListSnapshotsResponse, QdrantError>

List collection snapshots on this node.

client.list_snapshots("my_collection").await?;

Note: Snapshots are node-local. They only contain data of a single node. In distributed mode you must create a snapshot on each node separately. Each node has their own list of snapshots.

Documentation: https://qdrant.tech/documentation/concepts/snapshots/#list-snapshot

Source

pub async fn download_snapshot( &self, download: impl Into<SnapshotDownload>, ) -> Result<(), QdrantError>

Download a collection snapshot on this node.

use qdrant_client::qdrant::SnapshotDownloadBuilder;

client.download_snapshot(
    SnapshotDownloadBuilder::new("./target_path.snapshot", "my_collection")
        .snapshot_name("snapshot_name")
        .rest_api_uri("http://localhost:6333")
).await?;

let snapshot_file = File::open("./target_path.snapshot")?;

Note: Snapshots are node-local. They only contain data of a single node. In distributed mode you must create a snapshot on each node separately. Each node has their own list of snapshots.

Documentation: https://qdrant.tech/documentation/concepts/snapshots/#retrieve-snapshot

Source

pub async fn delete_snapshot( &self, request: impl Into<DeleteSnapshotRequest>, ) -> Result<DeleteSnapshotResponse, QdrantError>

Delete a collection snapshot on this node.

use qdrant_client::qdrant::DeleteSnapshotRequestBuilder;

client
    .delete_snapshot(DeleteSnapshotRequestBuilder::new(
        "my_collection",
        "snapshot_name",
    ))
    .await?;

Note: Snapshots are node-local. They only contain data of a single node. In distributed mode you must create a snapshot on each node separately. Each node has their own list of snapshots.

Documentation: https://qdrant.tech/documentation/concepts/snapshots/#delete-snapshot

Source

pub async fn create_full_snapshot( &self, ) -> Result<CreateSnapshotResponse, QdrantError>

Create full snapshot of this entire node.

Only supported in single-node deployment. Multi-node (distributed) mode is not supported.
client.create_full_snapshot().await?;

Documentation: https://qdrant.tech/documentation/concepts/snapshots/#create-full-storage-snapshot

Source

pub async fn list_full_snapshots( &self, ) -> Result<ListSnapshotsResponse, QdrantError>

List full snapshots of this node.

client.list_full_snapshots().await?;

Documentation: https://qdrant.tech/documentation/concepts/snapshots/#list-full-storage-snapshots

Source

pub async fn delete_full_snapshot( &self, request: impl Into<DeleteFullSnapshotRequest>, ) -> Result<DeleteSnapshotResponse, QdrantError>

Delete full snapshots of this node.

client
    .delete_full_snapshot("snapshot_name")
    .await?;

Documentation: https://qdrant.tech/documentation/concepts/snapshots/#delete-full-storage-snapshot

Source§

impl Qdrant

§Construct and connect

Methods to construct a new Qdrant client.

Source

pub fn new(config: QdrantConfig) -> Result<Self, QdrantError>

Create a new Qdrant client.

Constructs the client and connects based on the given QdrantConfig.

Source

pub fn from_url(url: &str) -> QdrantBuilder

Build a new Qdrant client with the given URL.

use qdrant_client::Qdrant;

let client = Qdrant::from_url("http://localhost:6334").build()?;

See more ways to set up the client here.

Source

pub async fn health_check(&self) -> Result<HealthCheckReply, QdrantError>

Health check.

Do a health check and fetch server information such as the current version and commit.

client.health_check().await?;

Trait Implementations§

Source§

impl Clone for Qdrant

Source§

fn clone(&self) -> Qdrant

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more