Skip to main content

VectorizerClient

Struct VectorizerClient 

Source
pub struct VectorizerClient { /* private fields */ }
Expand description

Vectorizer REST client with optional master/replica topology support. Public surface is identical to the pre-phase4 monolithic VectorizerClient; the methods are now organised across per-surface impl blocks (see module docs).

Implementations§

Source§

impl VectorizerClient

Source

pub async fn list_collections(&self) -> Result<Vec<Collection>>

List every collection visible to the authenticated principal. Accepts both the legacy bare-array response and the newer {collections: [...]} wrapper.

Source

pub async fn create_collection( &self, name: &str, dimension: usize, metric: Option<SimilarityMetric>, ) -> Result<CollectionInfo>

Create a new collection. The returned CollectionInfo is synthesised from the server’s create-response plus the arguments — the server response only carries the collection name today.

Source

pub async fn delete_collection(&self, name: &str) -> Result<()>

Delete a collection by name.

Source

pub async fn get_collection_info( &self, collection: &str, ) -> Result<CollectionInfo>

Fetch metadata for a collection (vector count, dimension, metric, timestamps, indexing status).

Source§

impl VectorizerClient

Source

pub async fn health_check(&self) -> Result<HealthStatus>

Check server health.

Source

pub async fn login(&self, username: &str, password: &str) -> Result<JwtToken>

Exchange a (username, password) pair for a JWT via POST /auth/login. The returned token is not retained by self — the transport was built with whatever credential (or none) was passed at construction. To use the JWT for subsequent requests, construct a new client with ClientConfig::api_key = Some(jwt.access_token); the HTTP transport recognises the three-segment JWT shape and sends it as Authorization: Bearer … rather than X-API-Key.

When the server runs with auth.enabled: false this endpoint may 404 — callers running against a no-auth dev server don’t need to call login at all.

Source§

impl VectorizerClient

Source

pub async fn discover( &self, query: &str, include_collections: Option<Vec<String>>, exclude_collections: Option<Vec<String>>, max_bullets: Option<usize>, broad_k: Option<usize>, focus_k: Option<usize>, ) -> Result<Value>

End-to-end discovery pipeline with intelligent search and LLM-style bullet generation.

Source

pub async fn filter_collections( &self, query: &str, include: Option<Vec<String>>, exclude: Option<Vec<String>>, ) -> Result<Value>

Pre-filter collections by name patterns.

Source

pub async fn score_collections( &self, query: &str, name_match_weight: Option<f32>, term_boost_weight: Option<f32>, signal_boost_weight: Option<f32>, ) -> Result<Value>

Rank collections by relevance to a query. The three weights must each be in [0.0, 1.0] when supplied.

Source

pub async fn expand_queries( &self, query: &str, max_expansions: Option<usize>, include_definition: Option<bool>, include_features: Option<bool>, include_architecture: Option<bool>, ) -> Result<Value>

Generate query variations (definition / features / architecture-style expansions, capped by max_expansions).

Source§

impl VectorizerClient

Source

pub async fn get_file_content( &self, collection: &str, file_path: &str, max_size_kb: Option<usize>, ) -> Result<Value>

Retrieve the complete content of an indexed file.

Source

pub async fn list_files_in_collection( &self, collection: &str, filter_by_type: Option<Vec<String>>, min_chunks: Option<usize>, max_results: Option<usize>, sort_by: Option<&str>, ) -> Result<Value>

List indexed files in a collection, optionally filtered by extension and minimum chunk count.

Source

pub async fn get_file_summary( &self, collection: &str, file_path: &str, summary_type: Option<&str>, max_sentences: Option<usize>, ) -> Result<Value>

Get an extractive or structural summary of one indexed file.

Source

pub async fn get_file_chunks_ordered( &self, collection: &str, file_path: &str, start_chunk: Option<usize>, limit: Option<usize>, include_context: Option<bool>, ) -> Result<Value>

Retrieve chunks in original file order for progressive reading. Pair with start_chunk + limit to page.

Source

pub async fn get_project_outline( &self, collection: &str, max_depth: Option<usize>, include_summaries: Option<bool>, highlight_key_files: Option<bool>, ) -> Result<Value>

Generate a hierarchical project structure overview.

Find semantically-related files by vector similarity.

Source

pub async fn search_by_file_type( &self, collection: &str, query: &str, file_types: Vec<String>, limit: Option<usize>, return_full_files: Option<bool>, ) -> Result<Value>

Semantic search filtered by file type. Empty file_types is rejected — pass at least one extension.

Source

pub async fn upload_file( &self, file_bytes: Vec<u8>, filename: &str, collection_name: &str, options: UploadFileOptions, ) -> Result<FileUploadResponse>

Upload a file for automatic text extraction, chunking, and indexing.

§Arguments
  • file_bytes - File content as bytes
  • filename - Name of the file (used for extension detection)
  • collection_name - Target collection name
  • options - Upload options (chunk size, overlap, metadata)
§Example
use vectorizer_sdk::{VectorizerClient, ClientConfig, UploadFileOptions};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ClientConfig::default();
    let client = VectorizerClient::new(config)?;

    let file_bytes = std::fs::read("document.pdf")?;
    let options = UploadFileOptions::default();

    let response = client.upload_file(
        file_bytes,
        "document.pdf",
        "my-docs",
        options
    ).await?;

    println!("Uploaded: {} chunks created", response.chunks_created);
    Ok(())
}
Source

pub async fn upload_file_content( &self, content: &str, filename: &str, collection_name: &str, options: UploadFileOptions, ) -> Result<FileUploadResponse>

Upload file content directly as a string. Convenience wrapper around Self::upload_file.

§Example
use vectorizer_sdk::{VectorizerClient, ClientConfig, UploadFileOptions};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = VectorizerClient::new(ClientConfig::default())?;
    let code = r#"fn main() { println!("Hello!"); }"#;
    let response = client.upload_file_content(
        code, "main.rs", "rust-code", UploadFileOptions::default()
    ).await?;
    println!("Uploaded: {} vectors created", response.vectors_created);
    Ok(())
}
Source

pub async fn get_upload_config(&self) -> Result<FileUploadConfig>

Get file upload configuration from the server (max file size, allowed extensions, default chunk settings).

§Example
use vectorizer_sdk::{VectorizerClient, ClientConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = VectorizerClient::new(ClientConfig::default())?;
    let upload_config = client.get_upload_config().await?;
    println!("Max file size: {}MB", upload_config.max_file_size_mb);
    Ok(())
}
Source§

impl VectorizerClient

Source

pub async fn list_graph_nodes( &self, collection: &str, ) -> Result<ListNodesResponse>

List every node in a collection’s graph.

Source

pub async fn get_graph_neighbors( &self, collection: &str, node_id: &str, ) -> Result<GetNeighborsResponse>

Get neighbours of a specific node.

Find related nodes within N hops.

Source

pub async fn find_graph_path( &self, request: FindPathRequest, ) -> Result<FindPathResponse>

Find the shortest path between two nodes.

Source

pub async fn create_graph_edge( &self, request: CreateEdgeRequest, ) -> Result<CreateEdgeResponse>

Create an explicit edge between two nodes.

Source

pub async fn delete_graph_edge(&self, edge_id: &str) -> Result<()>

Delete an edge by id.

Source

pub async fn list_graph_edges( &self, collection: &str, ) -> Result<ListEdgesResponse>

List every edge in a collection.

Source

pub async fn discover_graph_edges( &self, collection: &str, request: DiscoverEdgesRequest, ) -> Result<DiscoverEdgesResponse>

Discover SIMILAR_TO edges for an entire collection.

Source

pub async fn discover_graph_edges_for_node( &self, collection: &str, node_id: &str, request: DiscoverEdgesRequest, ) -> Result<DiscoverEdgesResponse>

Discover SIMILAR_TO edges for one specific node.

Source

pub async fn get_graph_discovery_status( &self, collection: &str, ) -> Result<DiscoveryStatusResponse>

Get discovery status for a collection.

Source§

impl VectorizerClient

Source

pub async fn qdrant_list_collections(&self) -> Result<Value>

List all collections (Qdrant-compatible).

Source

pub async fn qdrant_get_collection(&self, name: &str) -> Result<Value>

Get one collection’s metadata (Qdrant-compatible).

Source

pub async fn qdrant_create_collection( &self, name: &str, config: &Value, ) -> Result<Value>

Create a collection (Qdrant-compatible).

Source

pub async fn qdrant_upsert_points( &self, collection: &str, points: &Value, wait: bool, ) -> Result<Value>

Upsert points into a collection (Qdrant-compatible).

Source

pub async fn qdrant_search_points( &self, collection: &str, vector: &[f32], limit: Option<usize>, filter: Option<&Value>, with_payload: bool, with_vector: bool, ) -> Result<Value>

Search points (Qdrant-compatible).

Source

pub async fn qdrant_delete_points( &self, collection: &str, point_ids: &[Value], wait: bool, ) -> Result<Value>

Delete points by id (Qdrant-compatible).

Source

pub async fn qdrant_retrieve_points( &self, collection: &str, point_ids: &[Value], with_payload: bool, with_vector: bool, ) -> Result<Value>

Retrieve points by id (Qdrant-compatible).

Source

pub async fn qdrant_count_points( &self, collection: &str, filter: Option<&Value>, ) -> Result<Value>

Count points (Qdrant-compatible).

Source

pub async fn qdrant_list_collection_snapshots( &self, collection: &str, ) -> Result<Value>

List snapshots for a collection (Qdrant-compatible).

Source

pub async fn qdrant_create_collection_snapshot( &self, collection: &str, ) -> Result<Value>

Create a snapshot for a collection (Qdrant-compatible).

Source

pub async fn qdrant_delete_collection_snapshot( &self, collection: &str, snapshot_name: &str, ) -> Result<Value>

Delete a snapshot (Qdrant-compatible).

Source

pub async fn qdrant_recover_collection_snapshot( &self, collection: &str, location: &str, ) -> Result<Value>

Recover a collection from a snapshot location (Qdrant-compatible).

Source

pub async fn qdrant_list_all_snapshots(&self) -> Result<Value>

List all snapshots across collections (Qdrant-compatible).

Source

pub async fn qdrant_create_full_snapshot(&self) -> Result<Value>

Create a full-cluster snapshot (Qdrant-compatible).

Source

pub async fn qdrant_list_shard_keys(&self, collection: &str) -> Result<Value>

List shard keys for a collection (Qdrant-compatible).

Source

pub async fn qdrant_create_shard_key( &self, collection: &str, shard_key: &Value, ) -> Result<Value>

Create a shard key (Qdrant-compatible).

Source

pub async fn qdrant_delete_shard_key( &self, collection: &str, shard_key: &Value, ) -> Result<Value>

Delete a shard key (Qdrant-compatible).

Source

pub async fn qdrant_get_cluster_status(&self) -> Result<Value>

Get cluster status (Qdrant-compatible).

Source

pub async fn qdrant_cluster_recover(&self) -> Result<Value>

Trigger a cluster recovery on the current peer (Qdrant-compatible).

Source

pub async fn qdrant_remove_peer(&self, peer_id: &str) -> Result<Value>

Remove a peer from the cluster (Qdrant-compatible).

Source

pub async fn qdrant_list_metadata_keys(&self) -> Result<Value>

List metadata keys (Qdrant-compatible).

Source

pub async fn qdrant_get_metadata_key(&self, key: &str) -> Result<Value>

Get one metadata key (Qdrant-compatible).

Source

pub async fn qdrant_update_metadata_key( &self, key: &str, value: &Value, ) -> Result<Value>

Update one metadata key (Qdrant-compatible).

Source

pub async fn qdrant_query_points( &self, collection: &str, request: &Value, ) -> Result<Value>

Query points using the Qdrant 1.7+ Query API.

Source

pub async fn qdrant_batch_query_points( &self, collection: &str, request: &Value, ) -> Result<Value>

Batch-query points using the Qdrant 1.7+ Query API.

Source

pub async fn qdrant_query_points_groups( &self, collection: &str, request: &Value, ) -> Result<Value>

Query points with grouping (Qdrant 1.7+ Query API).

Source

pub async fn qdrant_search_points_groups( &self, collection: &str, request: &Value, ) -> Result<Value>

Search points with grouping (Qdrant Search Groups API).

Source

pub async fn qdrant_search_matrix_pairs( &self, collection: &str, request: &Value, ) -> Result<Value>

Search matrix pairs (Qdrant Search Matrix API).

Source

pub async fn qdrant_search_matrix_offsets( &self, collection: &str, request: &Value, ) -> Result<Value>

Search matrix offsets (Qdrant Search Matrix API).

Source§

impl VectorizerClient

Source

pub async fn search_vectors( &self, collection: &str, query: &str, limit: Option<usize>, score_threshold: Option<f32>, ) -> Result<SearchResponse>

Text search against one collection. The server embeds the query with the collection’s provider, runs ANN search, and returns up to limit (default 10) hits scored above the optional score_threshold.

Intelligent search — multi-query expansion + MMR diversification + domain term boosting.

Semantic search — advanced reranking + similarity-threshold filtering on top of the base text search.

Context-aware search with metadata filtering and contextual reranking.

Multi-collection search with cross-collection reranking and aggregation.

Hybrid search combining dense and sparse vectors with one of three scoring algorithms (RRF, weighted, alpha-blending).

Source§

impl VectorizerClient

Source

pub async fn get_vector( &self, collection: &str, vector_id: &str, ) -> Result<Vector>

Fetch one vector by id.

Server caveat (observed on hivehub/vectorizer:3.0.x): the GET /collections/{c}/vectors/{id} endpoint currently returns HTTP 200 with a synthetic uniform-vector payload ([0.1, 0.1, …]) even for ids that don’t exist. Callers that need real miss detection should probe via [VectorizerClient::list_vectors] or search and not trust an Ok(Vector) as proof of existence until the server fix ships.

Source

pub async fn insert_texts( &self, collection: &str, texts: Vec<BatchTextRequest>, ) -> Result<BatchResponse>

Insert a batch of texts into a collection. The server embeds each entry with the collection’s configured provider (BM25 by default; FastEmbed ONNX when selected in config.yml).

Wire contract: the server’s POST /insert_texts handler expects { "collection": "<name>", "texts": [...] } — the collection is a top-level field in the JSON body, not a path segment. The earlier POST /collections/{c}/documents path this method used was never served (the 3.0.x server returns 404 for it) and has been removed.

Per-entry id field: the server reassigns every inserted vector a server-generated UUID regardless of what the caller sent. The original client id is stashed as client_id on the response entry. Callers that need idempotency by client id should key off the client_id round-trip, not the server-assigned UUID.

Source

pub async fn embed_text( &self, text: &str, model: Option<&str>, ) -> Result<EmbeddingResponse>

Generate an embedding for text using either the supplied model name or the server default.

Source§

impl VectorizerClient

Source

pub fn base_url(&self) -> &str

Get the base URL the client is configured against.

Source

pub fn new(config: ClientConfig) -> Result<Self>

Create a new client with the given configuration.

Source

pub fn new_default() -> Result<Self>

Create a new client with default configuration.

Source

pub fn new_with_url(base_url: &str) -> Result<Self>

Create a client with a custom base URL.

Source

pub fn new_with_api_key(base_url: &str, api_key: &str) -> Result<Self>

Create a client with a custom base URL + API key.

Source

pub fn from_connection_string( connection_string: &str, api_key: Option<&str>, ) -> Result<Self>

Create a client from a full connection string (http(s)://host[:port] or umicp://host[:port]).

Source

pub fn protocol(&self) -> Protocol

Returns the protocol the client is currently using.

Source

pub async fn with_master<F, Fut, T>(&self, callback: F) -> Result<T>
where F: FnOnce(VectorizerClient) -> Fut, Fut: Future<Output = Result<T>>,

Execute a callback with master transport for read-your-writes scenarios. All operations within the callback are routed to master.

Source

pub fn with_transport( transport: Arc<dyn Transport>, base_url: impl Into<String>, ) -> Self

Construct a VectorizerClient directly from a custom Transport implementation. Test-only / advanced use.

The dispatcher fields (master_transport, replica_transports, is_replica_mode) are all left empty — the client behaves as a single-transport instance. Used by mock-based tests to swap the real HTTP backend out for an in-memory one without touching the per-surface modules.

This entry point is the RPC-readiness regression guard (phase 4 task 2.4): if any per-surface module accidentally hard-codes HttpTransport or reqwest::Client, the MockTransport integration test in tests/mock_transport_regression.rs stops compiling. The same Transport trait the crate::rpc backend will plug into from phase6_sdk-rust-rpc is what mocks ride here.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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, 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<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