Skip to main content

laurus/vector/store/
response.rs

1//! Vector store search response types.
2//!
3//! This module provides types for representing search results, hit information,
4//! and collection-level statistics returned from vector search operations.
5
6use std::collections::HashMap;
7
8use serde::{Deserialize, Serialize};
9
10use crate::vector::index::field::{FieldHit, VectorFieldStats};
11
12/// Results returned from a vector search operation.
13///
14/// Contains a list of [`VectorHit`] entries ranked by relevance score.
15#[derive(Debug, Clone, Serialize, Deserialize, Default)]
16pub struct VectorSearchResults {
17    /// Ranked list of document hits matching the query vectors.
18    #[serde(default)]
19    pub hits: Vec<VectorHit>,
20}
21
22/// Aggregated statistics describing a collection and its fields.
23#[derive(Debug, Clone, Default)]
24pub struct VectorStats {
25    /// Total number of documents in the collection.
26    pub document_count: usize,
27    /// Per-field statistics, keyed by field name.
28    pub fields: HashMap<String, VectorFieldStats>,
29}
30
31/// A single document hit from a vector search.
32///
33/// Represents a matched document together with its aggregated similarity
34/// score and the per-field hit details that contributed to the match.
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct VectorHit {
37    /// Unique identifier of the matched document.
38    pub doc_id: u64,
39    /// Aggregated similarity score for this document across all query vectors
40    /// and matched fields, computed according to the chosen [`VectorScoreMode`](crate::vector::store::request::VectorScoreMode).
41    pub score: f32,
42    /// Per-field hit details showing which fields matched and their individual scores.
43    #[serde(default)]
44    pub field_hits: Vec<FieldHit>,
45}