Skip to main content

qdrant_edge/edge/requests/
search.rs

1use crate::common::types::ScoreType;
2use crate::segment::data_types::load_profile::LoadProfile;
3use crate::segment::types::{Filter, SearchParams, WithPayloadInterface, WithVector};
4use crate::shard::query::query_enum::QueryEnum;
5use crate::shard::search::CoreSearchRequest;
6
7/// Single-query vector search over an edge shard.
8///
9/// DEPRECATED together with [`EdgeShardRead::search`](crate::EdgeShardRead::search): prefer
10/// [`QueryRequest`](crate::QueryRequest) and [`EdgeShardRead::query`](crate::EdgeShardRead::query).
11#[derive(Clone, Debug, PartialEq)]
12pub struct SearchRequest {
13    /// Every kind of query that can be performed on segment level.
14    pub query: QueryEnum,
15    /// Look only for points which satisfy these conditions.
16    pub filter: Option<Filter>,
17    /// Additional search params.
18    pub params: Option<SearchParams>,
19    /// Max number of results to return.
20    pub limit: usize,
21    /// Offset of the first result to return. May be used to paginate results.
22    /// Note: large offset values may cause performance issues.
23    pub offset: usize,
24    /// Select which payload to return with the response. Default is false.
25    pub with_payload: Option<WithPayloadInterface>,
26    /// Options for specifying which vectors to include into the response. Default is false.
27    pub with_vector: Option<WithVector>,
28    /// Exclude results with a worse score than this.
29    pub score_threshold: Option<ScoreType>,
30}
31
32impl SearchRequest {
33    pub fn new(query: QueryEnum, limit: usize) -> Self {
34        Self {
35            query,
36            filter: None,
37            params: None,
38            limit,
39            offset: 0,
40            with_payload: None,
41            with_vector: None,
42            score_threshold: None,
43        }
44    }
45
46    /// Request-specific [`LoadProfile`] for opening a read-only shard to serve exactly
47    /// this search: only the queried vector's components and the filter's field indexes
48    /// keep their configured placement.
49    pub fn load_profile(&self) -> LoadProfile {
50        CoreSearchRequest::from(self.clone()).load_profile()
51    }
52}