### Rust: Configure DiscoverPointsBuilder Context Examples Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.DiscoverPointsBuilder_search=std%3A%3Avec Sets the context examples for the DiscoverPointsBuilder. These pairs of examples constrain the search, guiding the discovery process based on provided data. ```rust pub fn context(self, value: Vec) -> Self ``` -------------------------------- ### Adding Recommendation Examples Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.RecommendPointGroupsBuilder Adds positive or negative examples to the recommendation query. Positive examples guide the search towards similar vectors, while negative examples help avoid certain vectors. These examples are crucial for refining the recommendation results. ```rust pub fn add_positive( self, recommend_example: impl Into, ) -> Self ``` ```rust pub fn add_negative( self, recommend_example: impl Into, ) -> Self ``` -------------------------------- ### Add Positive Examples to RecommendPointsBuilder in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.RecommendPointsBuilder Shows how to add positive examples to the recommendation query. These examples help the builder find vectors similar to the provided ones. The method returns a mutable reference to the builder for chaining. ```rust pub fn add_positive( self, recommend_example: impl Into, ) -> Self ``` -------------------------------- ### Example Searches - General Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/sparse_vector_builder/struct.SparseVectorBuilder_search= Demonstrates common search patterns and type signatures used for querying data. These examples illustrate how to search for specific types, type conversions, and operations on optional values. ```text * std::vec * u32 -> bool * Option, (T -> U) -> Option ``` -------------------------------- ### VectorExample Struct Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.VectorExample_search= Represents an example vector within the Qdrant client. It contains an optional `Example` field. ```APIDOC ## Struct VectorExample ### Description Represents an example vector with an optional `Example` field. ### Fields * **example** (`Option`) - An optional field that holds the example vector data. ``` -------------------------------- ### Qdrant Client Setup Source: https://docs.rs/qdrant-client/latest/qdrant_client/struct.Qdrant_search=u32+-%3E+bool Demonstrates how to set up a Qdrant client to connect to a Qdrant instance using different configuration options. ```APIDOC ## Qdrant Client Setup ### Description Set up a `Qdrant` client to connect to a Qdrant instance with just an URL. ### Code Examples **Using URL only:** ```rust use qdrant_client::Qdrant; let client = Qdrant::from_url("http://localhost:6334").build()?; ``` **Using URL, API key, and timeout:** ```rust use qdrant_client::Qdrant; use std::time::Duration; let client = Qdrant::from_url("http://localhost:6334") .api_key(std::env::var("QDRANT_API_KEY")) .timeout(Duration::from_secs(10)) .build()?; ``` ``` -------------------------------- ### Create ProductQuantizationBuilder Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.ProductQuantizationBuilder Initializes a new ProductQuantizationBuilder with a specified compression ratio. This is the starting point for configuring quantization. ```rust pub fn new(compression: i32) -> Self ``` -------------------------------- ### Implement Conversions for Example Enum Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example_search= Provides implementations for converting between `Example`, `VectorExample`, `PointId`, and `Vector`. These conversions facilitate seamless data handling within the client. ```rust fn from(value: Example) -> Self fn from(value: PointId) -> Self fn from(value: Vector) -> Self ``` -------------------------------- ### Rust Enum Example Conversion Implementations Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates implementations for converting between `Example`, `VectorExample`, `PointId`, and `Vector`. These conversions facilitate data manipulation within the qdrant client. ```rust impl From for VectorExample impl From for Example impl From for Example ``` -------------------------------- ### Example Usage of MmrBuilder Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.MmrBuilder_search= Demonstrates how to use the MmrBuilder to create an MMR configuration with specific diversity and candidate limit values. This example showcases the builder pattern in action. ```rust use qdrant_client::qdrant::MmrBuilder; let mmr = MmrBuilder::with_params(0.6, 100).build(); ``` -------------------------------- ### DiscoverPointsBuilder Initialization Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.DiscoverPointsBuilder Creates a new instance of DiscoverPointsBuilder. Requires collection name, context examples, and a limit for the search results. ```rust pub fn new( collection_name: impl Into, context: impl Into>, limit: u64, ) -> Self ``` -------------------------------- ### Conversion Implementations for Example Enum Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example Details the implementations for converting between `Example`, `Vector`, and `PointId`. These conversions allow for seamless integration with other parts of the qdrant client library. ```rust impl From for VectorExample impl From for Example impl From for Example ``` -------------------------------- ### Set up Qdrant Client Source: https://docs.rs/qdrant-client/latest/qdrant_client/struct.Qdrant_search= Initializes a Qdrant client to connect to a Qdrant server. Supports basic URL connection and advanced configuration with API keys and timeouts. ```rust use qdrant_client::Qdrant; let client = Qdrant::from_url("http://localhost:6334").build()?; ``` ```rust 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()?; ``` -------------------------------- ### Encoding and Decoding Methods for Example Enum Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example Provides methods for encoding the `Example` enum into a buffer and decoding it from a buffer. It also includes a method to get the encoded length without a delimiter. ```rust pub fn encode(&self, buf: &mut impl BufMut) pub fn merge( field: &mut Option, tag: u32, wire_type: WireType, buf: &mut impl Buf, ctx: DecodeContext, ) -> Result<(), DecodeError> pub fn encoded_len(&self) -> usize ``` -------------------------------- ### Default Qdrant Client Configuration Source: https://docs.rs/qdrant-client/latest/qdrant_client/config/struct.QdrantConfig_search=u32+-%3E+bool Provides the default configuration for a Qdrant client. This default setup connects to `http://localhost:6334` without requiring an API key, offering a convenient starting point. ```rust fn default() -> Self ``` -------------------------------- ### QdrantServer Constructor and Configuration Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/qdrant_server/struct.QdrantServer_search= This section details how to create and configure a QdrantServer instance. ```APIDOC ## QdrantServer API ### Description Provides methods for creating and configuring a QdrantServer. ### Methods #### `new(inner: T) -> Self` Creates a new `QdrantServer` instance with the given inner service. #### `from_arc(inner: Arc) -> Self` Creates a new `QdrantServer` instance from an `Arc` of the inner service. #### `with_interceptor(inner: T, interceptor: F) -> InterceptedService` Creates a new `QdrantServer` with an interceptor. #### `accept_compressed(self, encoding: CompressionEncoding) -> Self` Enables decompressing requests with the specified encoding. #### `send_compressed(self, encoding: CompressionEncoding) -> Self` Compresses responses with the specified encoding, if the client supports it. #### `max_decoding_message_size(self, limit: usize) -> Self` Limits the maximum size of a decoded message. Default is `4MB`. #### `max_encoding_message_size(self, limit: usize) -> Self` Limits the maximum size of an encoded message. Default is `usize::MAX`. ``` -------------------------------- ### RecommendPoints API Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.RecommendPoints_search=u32+-%3E+bool The RecommendPoints struct is used to configure and execute recommendation queries in Qdrant. It allows specifying positive and negative examples, filters, limits, and other parameters to guide the search for similar points. ```APIDOC ## POST /recommend ### Description Executes a recommendation query to find points similar to a set of positive examples and dissimilar to a set of negative examples, optionally applying filters and other search parameters. ### Method POST ### Endpoint `/recommend` ### Parameters #### Request Body - **collection_name** (String) - Required - The name of the collection to perform the recommendation search in. - **positive** (Vec) - Required - A list of point IDs to use as positive examples. - **negative** (Vec) - Required - A list of point IDs to use as negative examples. - **filter** (Option) - Optional - Conditions to filter the results. - **limit** (u64) - Required - The maximum number of results to return. - **with_payload** (Option) - Optional - Specifies which payload fields to include in the response. - **params** (Option) - Optional - Configuration for the search parameters. - **score_threshold** (Option) - Optional - A threshold for the recommendation score; results below this score will be excluded. - **offset** (Option) - Optional - The number of results to skip from the beginning. - **using** (Option) - Optional - The name of the vector to use for recommendations. If not specified, the default vector is used. - **with_vectors** (Option) - Optional - Specifies whether to include vectors in the response. - **lookup_from** (Option) - Optional - The collection to use for looking up points. Defaults to the current collection. - **read_consistency** (Option) - Optional - Specifies read consistency guarantees for the operation. - **strategy** (Option) - Optional - Defines how to use the example vectors to find results. - **positive_vectors** (Vec) - Optional - A list of vectors to use as positive examples. - **negative_vectors** (Vec) - Optional - A list of vectors to use as negative examples. - **timeout** (Option) - Optional - Overrides the global timeout setting for this request in seconds. - **shard_key_selector** (Option) - Optional - Specifies the shards to search within. ### Request Example ```json { "collection_name": "my_collection", "positive": ["point1", "point2"], "negative": ["point3"], "limit": 10, "with_payload": {"enable": true}, "params": {"quantization": "product"} } ``` ### Response #### Success Response (200) - **result** (Array) - A list of recommended points, each containing `id`, `payload`, `score`, and optionally `vector`. #### Response Example ```json { "result": [ { "id": "recommended_point_1", "payload": {"key": "value"}, "score": 0.95, "vector": [0.1, 0.2, 0.3] } ] } ``` ``` -------------------------------- ### Get Element Offset in Rust Slice (Nightly) Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.ListValue The `element_offset` method returns the index of a given element reference within a slice. It relies on pointer arithmetic and returns `None` if the element reference is not aligned with the start of an element. This is a nightly-only experimental API. ```rust #![feature(substr_range)] let nums: &[u32] = &[1, 7, 1, 1]; let num = &nums[2]; assert_eq!(num, &1); assert_eq!(nums.element_offset(num), Some(2)); ``` ```rust #![feature(substr_range)] let arr: &[[u32; 2]] = &[[0, 1], [2, 3]]; let flat_arr: &[u32] = arr.as_flattened(); let ok_elm: &[u32; 2] = flat_arr[0..2].try_into().unwrap(); let weird_elm: &[u32; 2] = flat_arr[1..3].try_into().unwrap(); assert_eq!(ok_elm, &[0, 1]); assert_eq!(weird_elm, &[1, 2]); assert_eq!(arr.element_offset(ok_elm), Some(0)); // Points to element 0 assert_eq!(arr.element_offset(weird_elm), None); // Points between element 0 and 1 ``` -------------------------------- ### Build Qdrant Client from URL Source: https://docs.rs/qdrant-client/latest/qdrant_client/config/struct.QdrantConfig_search=u32+-%3E+bool Demonstrates how to start configuring a Qdrant client by providing the server URL. This is the initial step in building a client instance, often followed by setting other configuration options. ```rust use qdrant_client::Qdrant; use qdrant_client::config::CompressionEncoding; let client = Qdrant::from_url("http://localhost:6334") .api_key(std::env::var("QDRANT_API_KEY")) .timeout(std::time::Duration::from_secs(10)) .compression(Some(CompressionEncoding::Gzip)) .build(); ``` -------------------------------- ### Implement From for VectorExample in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.VectorExample Implements the `From` trait for `VectorExample` in Rust, enabling conversion from an `Example` type to a `VectorExample`. ```rust impl From for VectorExample { fn from(value: Example) -> Self { // ... implementation details ... } } ``` -------------------------------- ### QdrantServer Constructors and Configuration Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/qdrant_server/struct.QdrantServer Provides methods for creating and configuring QdrantServer instances. This includes basic constructors like `new` and `from_arc`, as well as methods to enable request/response compression, set message size limits, and integrate custom interceptors. ```rust pub fn new(inner: T) -> Self ``` ```rust pub fn from_arc(inner: Arc) -> Self ``` ```rust pub fn with_interceptor( inner: T, interceptor: F, ) -> InterceptedService where F: Interceptor, ``` ```rust pub fn accept_compressed(self, encoding: CompressionEncoding) -> Self ``` ```rust pub fn send_compressed(self, encoding: CompressionEncoding) -> Self ``` ```rust pub fn max_decoding_message_size(self, limit: usize) -> Self ``` ```rust pub fn max_encoding_message_size(self, limit: usize) -> Self ``` -------------------------------- ### Convert Vector to Example Enum in Qdrant Client Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example_search=std%3A%3Avec Implements the `From` trait to convert a `Vector` into the `Example` enum. This allows easy creation of `Example::Vector` variants. ```rust fn from(value: Vector) -> Self ``` -------------------------------- ### DocumentBuilder Initialization and Configuration Methods Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/document_builder/struct.DocumentBuilder_search=u32+-%3E+bool Provides methods for creating and configuring a `DocumentBuilder`. The `new` function initializes the builder with text and a model, while `text`, `model`, and `options` allow for incremental configuration. The `build` method finalizes the document construction. ```rust pub fn new(text: impl Into, model: impl Into) -> Self pub fn text(self, text: impl Into) -> Self pub fn model(self, model: impl Into) -> Self pub fn options(self, options: HashMap) -> Self pub fn build(self) -> Document ``` -------------------------------- ### POST /recommend_batch Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/points_client/struct.PointsClient_search= Recommends points based on positive and negative examples. This endpoint finds points that are closer to the stored positive examples and further from the negative examples. ```APIDOC ## POST /recommend_batch ### Description Look for the points which are closer to stored positive examples and at the same time further to negative examples. ### Method POST ### Endpoint /recommend_batch ### Parameters #### Request Body - **request** (RecommendBatchPoints) - Required - The request object containing positive and negative point IDs for recommendation. ### Request Example ```json { "positive": ["point_id_1", "point_id_2"], "negative": ["point_id_3", "point_id_4"], "query_filter": { ... }, "limit": 10 } ``` ### Response #### Success Response (200) - **result** (RecommendBatchResponse) - The response containing recommended points. #### Response Example ```json { "result": { "points": [ { "id": "recommended_point_id_1", "score": 0.95, "payload": { ... } } ] } } ``` ``` -------------------------------- ### Initialize RecommendPointsBuilder in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.RecommendPointsBuilder Demonstrates how to create a new instance of RecommendPointsBuilder. It requires the collection name and a limit for the number of recommendations. This is the starting point for building a recommendation query. ```rust pub fn new(collection_name: impl Into, limit: u64) -> Self ``` -------------------------------- ### Construct and Connect Source: https://docs.rs/qdrant-client/latest/qdrant_client/struct.Qdrant_search=u32+-%3E+bool Methods for creating a new Qdrant client instance. ```APIDOC ## POST /websites/rs_qdrant-client_qdrant_client/new ### Description Creates a new Qdrant client instance and establishes a connection based on the provided `QdrantConfig`. ### Method POST ### Endpoint /websites/rs_qdrant-client_qdrant_client/new ### Parameters #### Request Body - **config** (QdrantConfig) - Required - Configuration object for the Qdrant client. ### Response #### Success Response (200) - **QdrantClient** (object) - The newly created Qdrant client instance. #### Error Response (400/500) - **QdrantError** (object) - An error object if client creation or connection fails. ``` ```APIDOC ## POST /websites/rs_qdrant-client_qdrant_client/from_url ### Description Builds a new Qdrant client instance using a provided URL. ### Method POST ### Endpoint /websites/rs_qdrant-client_qdrant_client/from_url ### Parameters #### Request Body - **url** (string) - Required - The URL of the Qdrant instance (e.g., "http://localhost:6334"). ### Request Example ```json { "url": "http://localhost:6334" } ``` ### Response #### Success Response (200) - **QdrantBuilder** (object) - A builder object that can be used to finalize client construction. #### Error Response (400/500) - **QdrantError** (object) - An error object if the URL is invalid or connection fails. ``` -------------------------------- ### DocumentBuilder Initialization and Configuration Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/document_builder/struct.DocumentBuilder Methods for creating and configuring a `DocumentBuilder`. `new` initializes with text and model, `text` and `model` allow setting these fields, `options` adds custom key-value pairs, and `build` finalizes the document. ```rust pub fn new(text: impl Into, model: impl Into) -> Self ``` ```rust pub fn text(self, text: impl Into) -> Self ``` ```rust pub fn model(self, model: impl Into) -> Self ``` ```rust pub fn options(self, options: HashMap) -> Self ``` ```rust pub fn build(self) -> Document ``` -------------------------------- ### Implement From for Example in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.PointId Allows conversion of a PointId instance into an Example type. ```rust impl From for Example { fn from(value: PointId) -> Self } ``` -------------------------------- ### SnapshotsServer Initialization Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/snapshots_server/struct.SnapshotsServer_search=std%3A%3Avec Provides methods for creating new instances of SnapshotsServer, allowing for different initialization strategies. ```APIDOC ## SnapshotsServer ### Description Represents the server-side functionality for managing Qdrant snapshots. ### Methods #### `new(inner: T) -> Self` Creates a new `SnapshotsServer` instance with the given inner service. #### `from_arc(inner: Arc) -> Self` Creates a new `SnapshotsServer` instance from an `Arc`-wrapped inner service. #### `with_interceptor(inner: T, interceptor: F) -> InterceptedService` Creates a new `SnapshotsServer` instance with an added interceptor. * **`inner`** (T): The inner service to wrap. * **`interceptor`** (F): The interceptor function to apply. ### Configuration Methods These methods allow configuring the behavior of the `SnapshotsServer` before it's used. #### `accept_compressed(self, encoding: CompressionEncoding) -> Self` Enables decompressing incoming requests with the specified encoding. * **`encoding`** (CompressionEncoding): The compression encoding to accept. #### `send_compressed(self, encoding: CompressionEncoding) -> Self` Enables compressing responses with the specified encoding, if the client supports it. * **`encoding`** (CompressionEncoding): The compression encoding to send. #### `max_decoding_message_size(self, limit: usize) -> Self` Limits the maximum size of a decoded message. Defaults to `4MB`. * **`limit`** (usize): The maximum message size in bytes. #### `max_encoding_message_size(self, limit: usize) -> Self` Limits the maximum size of an encoded message. Defaults to `usize::MAX`. * **`limit`** (usize): The maximum message size in bytes. ``` -------------------------------- ### Collection Cluster Setup API Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/collections_server/trait.Collections_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Endpoint to update the cluster setup for a collection. ```APIDOC ## PUT /collections/{collection_name}/cluster/setup ### Description Update cluster setup for a collection. ### Method PUT ### Endpoint /collections/{collection_name}/cluster/setup ### Parameters #### Path Parameters - **collection_name** (string) - Required - The name of the collection. #### Request Body - **request** (UpdateCollectionClusterSetupRequest) - Required - Request object for updating cluster setup. ### Request Example ```json { "example": "UpdateCollectionClusterSetupRequest body" } ``` ### Response #### Success Response (200) - **response** (UpdateCollectionClusterSetupResponse) - Response indicating the result of the cluster setup update. #### Response Example ```json { "example": "UpdateCollectionClusterSetupResponse body" } ``` ``` -------------------------------- ### Getting a Ready Service Reference Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/collections_server/struct.CollectionsServer_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E These methods provide access to a service when it is ready to accept requests. `ready` yields a mutable reference, while `ready_oneshot` yields ownership of the service. `ready_and` is deprecated in favor of `ready`. ```rust fn ready(&mut self) -> Ready<'_, Self, Request> where Self: Sized, Yields a mutable reference to the service when it is ready to accept a request. ``` ```rust fn ready_and(&mut self) -> Ready<'_, Self, Request> where Self: Sized, Deprecated since 0.4.6: please use the `ServiceExt::ready` method instead Yields a mutable reference to the service when it is ready to accept a request. ``` ```rust fn ready_oneshot(self) -> ReadyOneshot where Self: Sized, Yields the service when it is ready to accept a request. ``` -------------------------------- ### Batch Recommend Points (Rust) Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/points_server/trait.Points Performs batch recommendations, finding points closer to positive examples and further from negative examples for multiple sets of examples. This function uses a `RecommendBatchPoints` request and returns a `RecommendBatchResponse`. It is an asynchronous operation. ```rust fn recommend_batch<'life0, 'async_trait>( &'life0 self, request: Request, ) -> Pin, Status>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, { // Implementation details for batch recommending points } ``` -------------------------------- ### Implement PartialEq for Example Enum Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example_search= Implements the `PartialEq` trait for the `Example` enum, enabling equality comparisons between instances. ```rust fn eq(&self, other: &Example) -> bool fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Recommend Batch Points Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/points_client/struct.PointsClient_search=u32+-%3E+bool Finds points similar to positive examples and dissimilar to negative examples in a batch. ```APIDOC ## POST /recommend/batch ### Description Look for the points which are closer to stored positive examples and at the same time further to negative examples. ### Method POST ### Endpoint /recommend/batch ### Parameters #### Request Body - **request** (RecommendBatchPoints) - Required - The request object containing positive and negative examples. ### Request Example ```json { "positive": [ {"id": 1, "vector": [0.1, 0.2]}, {"id": 2, "vector": [0.3, 0.4]} ], "negative": [ {"id": 3, "vector": [0.5, 0.6]}, {"id": 4, "vector": [0.7, 0.8]} ], "limit": 10 } ``` ### Response #### Success Response (200) - **result** (RecommendBatchResponse) - The response containing recommended points. #### Response Example ```json { "result": [ { "points": [ {"id": 5, "vector": [0.15, 0.25], "score": 0.9}, {"id": 6, "vector": [0.35, 0.45], "score": 0.85} ] } ] } ``` ``` -------------------------------- ### Rust BinaryQuantizationBuilder Initialization and Configuration Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.BinaryQuantizationBuilder Demonstrates how to initialize and configure a BinaryQuantizationBuilder. The `new` function creates an instance, and methods like `always_ram`, `encoding`, and `query_encoding` allow for setting specific quantization parameters. ```rust pub fn new(always_ram: bool) -> Self pub fn always_ram(self, value: bool) -> Self pub fn encoding(self, value: impl Into) -> Self pub fn query_encoding( self, value: impl Into, ) -> Self ``` -------------------------------- ### Recommend Batch Points Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/points_client/struct.PointsClient Finds points similar to positive examples and dissimilar to negative examples in a batch request. ```APIDOC ## POST /recommend/batch ### Description Look for the points which are closer to stored positive examples and at the same time further to negative examples. ### Method POST ### Endpoint /recommend/batch ### Parameters #### Request Body - **request** (RecommendBatchPoints) - Required - The request object containing positive and negative examples. ### Request Example ```json { "positive": [ {"id": 1, "vector": [0.1, 0.2]}, {"id": 2, "vector": [0.3, 0.4]} ], "negative": [ {"id": 3, "vector": [0.5, 0.6]}, {"id": 4, "vector": [0.7, 0.8]} ], "limit": 10 } ``` ### Response #### Success Response (200) - **result** (RecommendBatchResponse) - The response containing recommended points. #### Response Example ```json { "result": { "points": [ {"id": 5, "score": 0.9, "payload": {}}, {"id": 6, "score": 0.8, "payload": {}} ] } } ``` ``` -------------------------------- ### Build ContextExamplePair using Builder in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.ContextExamplePairBuilder Provides methods to build a `ContextExamplePair` using the `ContextExamplePairBuilder`. The `positive` and `negative` methods add example vectors, and the `build` method finalizes the construction. ```rust pub fn positive>(self, value: VALUE) -> Self pub fn negative>(self, value: VALUE) -> Self pub fn build(self) -> ContextExamplePair ``` -------------------------------- ### Implement Clone for Example Enum Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example_search=u32+-%3E+bool Implements the `Clone` trait for the `Example` enum, allowing instances to be duplicated. This includes both `clone` and `clone_from` methods. ```rust fn clone(&self) -> Example fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### CollectionsServer Initialization and Configuration Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/collections_server/struct.CollectionsServer This section covers the creation and configuration of the CollectionsServer, including methods for setting compression, message size limits, and interceptors. ```APIDOC ## CollectionsServer ### Description Represents the server-side component for managing collections in Qdrant. ### Methods #### `new(inner: T) -> Self` Creates a new `CollectionsServer` with the given inner service. #### `from_arc(inner: Arc) -> Self` Creates a new `CollectionsServer` from an `Arc`-wrapped inner service. #### `with_interceptor(inner: T, interceptor: F) -> InterceptedService` Creates a new `CollectionsServer` with a custom interceptor. - `F`: A type that implements the `Interceptor` trait. #### `accept_compressed(self, encoding: CompressionEncoding) -> Self` Enables decompressing requests with the specified encoding. - `encoding`: The `CompressionEncoding` to use for request decompression. #### `send_compressed(self, encoding: CompressionEncoding) -> Self` Compresses responses with the specified encoding, if the client supports it. - `encoding`: The `CompressionEncoding` to use for response compression. #### `max_decoding_message_size(self, limit: usize) -> Self` Limits the maximum size of a decoded message. - `limit`: The maximum size in bytes. Default: `4MB` #### `max_encoding_message_size(self, limit: usize) -> Self` Limits the maximum size of an encoded message. - `limit`: The maximum size in bytes. Default: `usize::MAX` ``` -------------------------------- ### Recommend Point Groups Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/points_client/struct.PointsClient Recommends points similar to positive examples and dissimilar to negative examples, grouped by a specified field. ```APIDOC ## POST /recommend/groups ### Description Look for the points which are closer to stored positive examples and at the same time further to negative examples, grouped by a given field. ### Method POST ### Endpoint /recommend/groups ### Parameters #### Request Body - **request** (RecommendPointGroups) - Required - The request object containing grouping and recommendation criteria. ### Request Example ```json { "positive": [ {"id": 1, "vector": [0.1, 0.2]} ], "negative": [ {"id": 2, "vector": [0.3, 0.4]} ], "group_by": "category", "limit": 5 } ``` ### Response #### Success Response (200) - **result** (RecommendGroupsResponse) - The response containing recommended points grouped by the specified field. #### Response Example ```json { "result": { "groups": [ { "group_id": { "any": "category_a" }, "hits": [ {"id": 3, "score": 0.9, "payload": {}}, {"id": 4, "score": 0.8, "payload": {}} ] } ] } } ``` ``` -------------------------------- ### Create SnapshotsServer Instance in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/snapshots_server/struct.SnapshotsServer_search=u32+-%3E+bool Demonstrates how to create instances of the SnapshotsServer struct. It shows the basic constructor `new` and a constructor that takes an `Arc` for shared ownership. It also includes methods for configuring compression and message size limits. ```Rust pub struct SnapshotsServer { /* private fields */ } impl SnapshotsServer { pub fn new(inner: T) -> Self; pub fn from_arc(inner: Arc) -> Self; pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: Interceptor; pub fn accept_compressed(self, encoding: CompressionEncoding) -> Self; pub fn send_compressed(self, encoding: CompressionEncoding) -> Self; pub fn max_decoding_message_size(self, limit: usize) -> Self; pub fn max_encoding_message_size(self, limit: usize) -> Self; } ``` -------------------------------- ### Update Collection Cluster Setup API Source: https://docs.rs/qdrant-client/latest/qdrant_client/struct.Qdrant_search=std%3A%3Avec Updates the cluster setup for a collection, allowing operations like moving or replicating shards. ```APIDOC ## POST /collections/{collection_name}/cluster/setup ### Description Updates the cluster setup for a collection. This endpoint supports operations such as `MoveShard`, `ReplicateShard`, or `CreateShardKey`. ### Method POST ### Endpoint /collections/{collection_name}/cluster/setup ### Parameters #### Path Parameters - **collection_name** (string) - Required - The name of the collection. #### Query Parameters None #### Request Body - **UpdateCollectionClusterSetupRequest** (object) - Required - Specifies the cluster operation to perform. - **operation** (object) - Required - The cluster operation details (e.g., `MoveShard`, `ReplicateShard`, `CreateShardKey`). - **MoveShard** (object) - Details for moving a shard. - **shard_id** (integer) - Required - The ID of the shard to move. - **from_peer_id** (integer) - Required - The ID of the source peer. - **to_peer_id** (integer) - Required - The ID of the destination peer. ### Request Example ```json { "operation": { "MoveShard": { "shard_id": 0, "from_peer_id": 0, "to_peer_id": 1 } } } ``` ### Response #### Success Response (200) - **status** (string) - The status of the operation. - **result** (boolean) - Indicates if the operation was successful. #### Response Example ```json { "status": "ok", "result": true } ``` ``` -------------------------------- ### Qdrant Client Initialization and Configuration (Rust) Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/points_client/struct.PointsClient_search=u32+-%3E+bool Demonstrates how to initialize and configure the PointsClient in Rust. This includes connecting to an endpoint, creating a client with default settings, or customizing it with an origin or interceptor. It also covers configuring compression and message size limits. ```rust use qdrant_client::qdrant::points_client::PointsClient; use qdrant_client::qdrant::client_config::ClientConfig; use qdrant_client::qdrant::errors::Error; use tonic::transport::Endpoint; use std::convert::TryInto; // Example of connecting to a default endpoint async fn connect_client() -> Result, Error> { PointsClient::connect("http://localhost:6334").await } // Example of creating a client with a custom inner service and origin fn create_client_with_origin(inner: T, origin: Uri) -> PointsClient where T: GrpcService, T::Error: Into, { PointsClient::with_origin(inner, origin) } // Example of creating a client with an interceptor fn create_client_with_interceptor(inner: T, interceptor: F) -> PointsClient> where F: Interceptor, T: GrpcService, T::Error: Into + Send + Sync, T::ResponseBody: Default, T: Service, Response = Response<>::ResponseBody>>, >>::Error: Into + Send + Sync, { PointsClient::with_interceptor(inner, interceptor) } // Example of configuring compression and message size limits fn configure_client(inner: T) -> PointsClient where T: GrpcService, T::Error: Into, { PointsClient::new(inner) .send_compressed(CompressionEncoding::Gzip) .accept_compressed(CompressionEncoding::Gzip) .max_decoding_message_size(1024 * 1024 * 10) // 10MB limit .max_encoding_message_size(1024 * 1024 * 5) // 5MB limit } ``` -------------------------------- ### Create and Build SnapshotDownload in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.SnapshotDownloadBuilder Shows how to instantiate a new SnapshotDownloadBuilder with required parameters and how to finalize the builder to create a SnapshotDownload object. ```rust pub fn new( out_path: impl Into, collection_name: impl Into, ) -> Self ``` ```rust pub fn build(self) -> SnapshotDownload ``` -------------------------------- ### Implement Clone and Debug for Example Enum Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example_search= Implements the `Clone` and `Debug` traits for the `Example` enum, allowing instances to be duplicated and formatted for debugging purposes. ```rust fn clone(&self) -> Example fn clone_from(&mut self, source: &Self) fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### Update Collection Cluster Setup in Qdrant Client Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/collections_server/trait.Collections_search=std%3A%3Avec Updates the cluster setup configuration for a collection in Qdrant. The operation is asynchronous. ```rust fn update_collection_cluster_setup<'life0, 'async_trait>( &'life0 self, request: Request, ) -> Pin, Status>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, { // Implementation details for updating cluster setup } ``` -------------------------------- ### Service Readiness Methods Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/qdrant_server/struct.QdrantServer_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods for checking and obtaining a service ready to accept requests. These include yielding a mutable reference or consuming the service. ```rust fn ready(&mut self) -> Ready<'_, Self, Request> where Self: Sized, Yields a mutable reference to the service when it is ready to accept a request. ``` ```rust fn ready_oneshot(self) -> ReadyOneshot where Self: Sized, Yields the service when it is ready to accept a request. ``` -------------------------------- ### Initialize QdrantConfig with URL Source: https://docs.rs/qdrant-client/latest/qdrant_client/config/struct.QdrantConfig_search=u32+-%3E+bool Shows how to create a QdrantConfig instance starting with a server URL. This method is typically used internally by the Qdrant client construction process. ```rust let client = QdrantConfig::from_url("http://localhost:6334").build(); ``` -------------------------------- ### Service Ready State Handling Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/points_server/struct.PointsServer_search= Methods to check and obtain a service when it's ready to accept requests. `ready` provides a mutable reference, `ready_oneshot` yields the service, and `oneshot` consumes the service to make a single request. ```rust fn ready(&mut self) -> Ready<'_, Self, Request> where Self: Sized; fn ready_oneshot(self) -> ReadyOneshot where Self: Sized; fn oneshot(self, req: Request) -> Oneshot where Self: Sized; ``` -------------------------------- ### Convert Example Enum to VectorExample in Qdrant Client Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example_search=std%3A%3Avec Implements the `From` trait to convert an `Example` enum into a `VectorExample`. This facilitates type conversions within the qdrant-client ecosystem. ```rust fn from(value: Example) -> Self ``` -------------------------------- ### CollectionsClient: Update Collection Cluster Setup Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/collections_client/struct.CollectionsClient_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Updates the cluster setup configuration for a Qdrant collection. It uses `UpdateCollectionClusterSetupRequest` and returns `Response`. ```rust use qdrant_client::qdrant::collections_client::CollectionsClient; use qdrant_client::qdrant::UpdateCollectionClusterSetupRequest; use qdrant_client::client::Response; use qdrant_client::qdrant::UpdateCollectionClusterSetupResponse; use tonic::Status; // Assuming 'client' is an initialized CollectionsClient instance // async fn update_collection_cluster_setup(client: &mut CollectionsClient>, request: UpdateCollectionClusterSetupRequest) -> Result, Status> { // client.update_collection_cluster_setup(request).await // } ``` -------------------------------- ### Rust Enum Example Encoding and Decoding Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods for encoding and decoding the `Example` enum to and from a buffer. The `encoded_len` method returns the message's encoded length. ```rust pub fn encode(&self, buf: &mut impl BufMut) pub fn merge( field: &mut Option, tag: u32, wire_type: WireType, buf: &mut impl Buf, ctx: DecodeContext, ) -> Result<(), DecodeError> pub fn encoded_len(&self) -> usize ``` -------------------------------- ### Initialize PointsClient in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/points_client/struct.PointsClient Demonstrates how to create a new PointsClient instance. This can be done by connecting to a specified endpoint or by providing an existing gRPC service client. ```rust use qdrant_client::qdrant::points_client::PointsClient; use qdrant_client::qdrant::Endpoint; use std::convert::TryInto; // Example using connect async fn connect_client() -> Result, Box> { let endpoint = "http://localhost:6334".try_into()?; let client = PointsClient::connect(endpoint).await?; Ok(client) } // Example using new with an existing service // Assuming 'inner_service' is a type that implements GrpcService // let client = PointsClient::new(inner_service); // Example using with_origin // let client = PointsClient::with_origin(inner_service, "http://localhost:6334".parse()?); // Example using with_interceptor // let client = PointsClient::with_interceptor(inner_service, my_interceptor); ``` -------------------------------- ### Service Readiness and Request Handling in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/snapshots_server/struct.SnapshotsServer_search=std%3A%3Avec These methods provide ways to interact with services when they are ready to accept requests. `ready` and `ready_and` yield a mutable reference, while `ready_oneshot` yields the service itself. `oneshot` consumes the service to process a single request. ```rust fn ready(&mut self) -> Ready<'_, Self, Request> where Self: Sized, Yields a mutable reference to the service when it is ready to accept a request. ``` ```rust fn ready_and(&mut self) -> Ready<'_, Self, Request> where Self: Sized, Deprecated since 0.4.6: please use the `ServiceExt::ready` method instead Yields a mutable reference to the service when it is ready to accept a request. ``` ```rust fn ready_oneshot(self) -> ReadyOneshot where Self: Sized, Yields the service when it is ready to accept a request. ``` ```rust fn oneshot(self, req: Request) -> Oneshot where Self: Sized, Consume this `Service`, calling with the providing request once it is ready. ``` -------------------------------- ### Rust Enum Example Definition Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/vector_example/enum.Example_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Defines an enum `Example` with variants `Id` and `Vector`. This enum is used to represent different types of data within the qdrant client. ```rust pub enum Example { Id(PointId), Vector(Vector), } ``` -------------------------------- ### Recommend Points using PointsClient in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/points_client/struct.PointsClient_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Looks for points that are closer to stored positive examples and further from negative examples. This is a specialized search for recommendation systems. ```rust pub async fn recommend( &mut self, request: impl IntoRequest, ) -> Result, Status> ``` -------------------------------- ### CreateCollectionBuilder Initialization and Configuration Methods (Rust) Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/create_collection_builder/struct.CreateCollectionBuilder_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the core methods of the CreateCollectionBuilder for initializing and configuring a new Qdrant collection. These methods allow setting the collection name, HNSW and WAL configurations, optimizer settings, shard count, on-disk payload, timeouts, vector configurations, replication factor, write consistency, quantization, sharding method, sparse vector configuration, strict mode, and metadata. ```rust pub fn new(collection_name: impl Into) -> Self pub fn collection_name>(self, value: VALUE) -> Self pub fn hnsw_config>(self, value: VALUE) -> Self pub fn wal_config>(self, value: VALUE) -> Self pub fn optimizers_config>( self, value: VALUE, ) -> Self pub fn shard_number(self, value: u32) -> Self pub fn on_disk_payload(self, value: bool) -> Self pub fn timeout(self, value: u64) -> Self pub fn vectors_config>(self, value: VALUE) -> Self pub fn replication_factor(self, value: u32) -> Self pub fn write_consistency_factor(self, value: u32) -> Self pub fn quantization_config>( self, value: VALUE, ) -> Self pub fn sharding_method(self, value: i32) -> Self pub fn sparse_vectors_config>( self, value: VALUE, ) -> Self pub fn strict_mode_config>( self, value: VALUE, ) -> Self pub fn metadata(self, value: impl Into) -> Self ``` -------------------------------- ### SnapshotDownloadBuilder Constructor and Build Method Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.SnapshotDownloadBuilder_search=u32+-%3E+bool Details the constructor `new` for SnapshotDownloadBuilder, which requires an output path and collection name. It also includes the `build` method, which finalizes the configuration and returns a `SnapshotDownload` object. ```rust pub fn new( out_path: impl Into, collection_name: impl Into, ) -> Self ``` ```rust pub fn build(self) -> SnapshotDownload ``` -------------------------------- ### Define VectorExample Struct in Rust Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/struct.VectorExample Defines the `VectorExample` struct in Rust, which contains an optional `Example` field. This struct is part of the qdrant_client library and is used for representing vector examples. ```rust pub struct VectorExample { pub example: Option, } ``` -------------------------------- ### Recommend Points Batch Source: https://docs.rs/qdrant-client/latest/qdrant_client/qdrant/points_client/struct.PointsClient_search=u32+-%3E+bool Recommends points based on positive and negative examples in a batch request. It identifies points closer to positive examples and further from negative ones. ```rust pub async fn recommend_batch( &mut self, request: impl IntoRequest, ) -> Result, Status> ```