pub struct VectorSearchResult {
pub record: Value,
pub score: Option<f64>,
pub score_kind: Option<String>,
}Expand description
One search hit: the record, and the provider’s score for it.
Fields§
§record: ValueThe record, keyed by logical field name.
score: Option<f64>The provider’s similarity or distance score, or None when the
provider reports none.
Read the direction from Self::score_kind when it is set, and only
otherwise from the collection’s
DistanceFunction::higher_is_closer.
score_kind: Option<String>What kind of number Self::score is, when the declared distance
function does not describe it.
The collection’s distance function is a request — rank by this — and
on several services it does not describe what comes back. Azure AI
Search answers a vector query with a relevance score where higher is
better whatever metric the profile declares, and answers a hybrid
query with a reciprocal-rank-fusion score that is not a distance at
all. A caller thresholding or fusing on score under the definition’s
higher_is_closer would invert the ranking, so the connector says
what it actually returned. Mirrors upstream’s score_kind result
metadata.
None means the score is in the collection’s declared distance
function, as InMemoryVectorStore returns. The values this workspace
emits are Self::SCORE_KIND_RELEVANCE and
Self::SCORE_KIND_RRF, both higher-is-closer.
Implementations§
Source§impl VectorSearchResult
impl VectorSearchResult
Sourcepub const SCORE_KIND_RELEVANCE: &'static str = "relevance"
pub const SCORE_KIND_RELEVANCE: &'static str = "relevance"
A provider relevance score: higher is a better match, and the value is not a distance in the declared metric.
Sourcepub const SCORE_KIND_RRF: &'static str = "rrf"
pub const SCORE_KIND_RRF: &'static str = "rrf"
A reciprocal-rank-fusion score from a hybrid query: higher is a better match, and it is a rank combination rather than any distance.
Sourcepub fn higher_is_closer(
&self,
distance: Option<&DistanceFunction>,
) -> Option<bool>
pub fn higher_is_closer( &self, distance: Option<&DistanceFunction>, ) -> Option<bool>
Whether a higher Self::score means a closer match, given the
collection’s declared distance function.
Prefers Self::score_kind over distance, which is the whole point
of the field: on a service that ignores the declared metric when
scoring, the definition is the wrong thing to read. None when
neither answers.
Trait Implementations§
Source§impl Clone for VectorSearchResult
impl Clone for VectorSearchResult
Source§fn clone(&self) -> VectorSearchResult
fn clone(&self) -> VectorSearchResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more