pub struct SearchRequestBuilder { /* private fields */ }Expand description
Fluent builder for constructing a SearchRequest.
Supports three construction patterns:
- DSL string (via
query_dsl): Pass a unified query DSL string. The engine parses it at search time. - Single mode (via
lexical_queryorvector_query): Set one search mode. - Hybrid (via both
lexical_queryandvector_query): Set both for hybrid search.
If query_dsl is called, the builder produces a
SearchQuery::Dsl variant. Otherwise, it determines the variant from
which query methods were called.
Implementations§
Source§impl SearchRequestBuilder
impl SearchRequestBuilder
Sourcepub fn query_dsl(self, dsl: impl Into<String>) -> Self
pub fn query_dsl(self, dsl: impl Into<String>) -> Self
Set a unified query DSL string.
When set, the built request uses SearchQuery::Dsl and any
lexical/vector queries set via other methods are ignored.
Sourcepub fn lexical_query(self, query: LexicalSearchQuery) -> Self
pub fn lexical_query(self, query: LexicalSearchQuery) -> Self
Set the lexical search query.
If vector_query is also set, the result is
SearchQuery::Hybrid. Otherwise SearchQuery::Lexical.
Sourcepub fn vector_query(self, query: VectorSearchQuery) -> Self
pub fn vector_query(self, query: VectorSearchQuery) -> Self
Set the vector search query.
If lexical_query is also set, the result is
SearchQuery::Hybrid. Otherwise SearchQuery::Vector.
Sourcepub fn fusion_algorithm(self, fusion: FusionAlgorithm) -> Self
pub fn fusion_algorithm(self, fusion: FusionAlgorithm) -> Self
Set the fusion algorithm for hybrid search.
For FusionAlgorithm::WeightedSum, the weights are clamped to
0.0..=1.0 to prevent NaN/Inf propagation.
Sourcepub fn filter_query(self, query: Box<dyn Query>) -> Self
pub fn filter_query(self, query: Box<dyn Query>) -> Self
Set a filter query to restrict the search space.
The filter applies to both lexical and vector searches.
Sourcepub fn add_field_boost(self, field: impl Into<String>, boost: f32) -> Self
pub fn add_field_boost(self, field: impl Into<String>, boost: f32) -> Self
Add a field-level boost for lexical search.
Sourcepub fn lexical_min_score(self, min_score: f32) -> Self
pub fn lexical_min_score(self, min_score: f32) -> Self
Set the minimum score threshold for lexical search.
Sourcepub fn lexical_timeout_ms(self, timeout_ms: u64) -> Self
pub fn lexical_timeout_ms(self, timeout_ms: u64) -> Self
Set the timeout for lexical search in milliseconds.
Sourcepub fn lexical_parallel(self, parallel: bool) -> Self
pub fn lexical_parallel(self, parallel: bool) -> Self
Enable or disable parallel lexical search.
Sourcepub fn sort_by(self, sort_by: SortField) -> Self
pub fn sort_by(self, sort_by: SortField) -> Self
Set the sort order for lexical search results.
Sourcepub fn vector_score_mode(self, score_mode: VectorScoreMode) -> Self
pub fn vector_score_mode(self, score_mode: VectorScoreMode) -> Self
Set the score combination mode for vector search.
Sourcepub fn vector_min_score(self, min_score: f32) -> Self
pub fn vector_min_score(self, min_score: f32) -> Self
Set the minimum score threshold for vector search.
Sourcepub fn build(self) -> SearchRequest
pub fn build(self) -> SearchRequest
Consume the builder and return the constructed SearchRequest.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SearchRequestBuilder
impl !RefUnwindSafe for SearchRequestBuilder
impl Send for SearchRequestBuilder
impl Sync for SearchRequestBuilder
impl Unpin for SearchRequestBuilder
impl UnsafeUnpin for SearchRequestBuilder
impl !UnwindSafe for SearchRequestBuilder
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.