pub struct Search<T: SurrealRecord> { /* private fields */ }Expand description
A full-text SELECT over a SEARCH-indexed field, reached from
Table::search. Renders SELECT … FROM <table> WHERE field @@ 'query',
and — once a match reference is set — can project
search::score(n) and order by relevance.
ⓘ
Post::table()
.search("body", "rust database")
.score_as("score") // SELECT *, search::score(0) AS score
.order_by_score() // ORDER BY search::score(0) DESC
.limit(10)
.to_surrealql();
// SELECT *, search::score(0) AS score FROM post
// WHERE body @0@ 'rust database' ORDER BY score DESC LIMIT 10Implementations§
Source§impl<T: SurrealRecord> Search<T>
impl<T: SurrealRecord> Search<T>
Sourcepub fn reference(self, n: u8) -> Self
pub fn reference(self, n: u8) -> Self
Set the match reference n explicitly (renders field @n@ 'query').
Sourcepub fn filter(self, expr: impl DynExpr + 'static) -> Self
pub fn filter(self, expr: impl DynExpr + 'static) -> Self
AND an additional predicate onto the WHERE clause.
Sourcepub fn score_as(self, alias: impl Into<String>) -> Self
pub fn score_as(self, alias: impl Into<String>) -> Self
Project the relevance score as search::score(n) AS <alias>. Enables the
match reference (@n@) so the score is computable.
Sourcepub fn order_by_score(self) -> Self
pub fn order_by_score(self) -> Self
ORDER BY <score> DESC — most relevant first. Projects the score (default
alias score) and enables the match reference, since ORDER BY sorts on
the projected alias rather than the search::score(n) call directly.
Sourcepub fn to_surrealql(&self) -> String
pub fn to_surrealql(&self) -> String
Render to a SurrealQL string with literals inlined.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Search<T>
impl<T> !UnwindSafe for Search<T>
impl<T> Freeze for Search<T>
impl<T> Send for Search<T>
impl<T> Sync for Search<T>
impl<T> Unpin for Search<T>where
T: Unpin,
impl<T> UnsafeUnpin for Search<T>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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 more