pub struct Query { /* private fields */ }
Expand description
A builder for LanceDB queries.
See crate::Table::query
for more details on queries
See QueryBase
for methods that can be used to parameterize
the query.
See ExecutableQuery
for methods that can be used to execute
the query and retrieve results.
This query object can be reused to issue the same query multiple times.
Implementations§
source§impl Query
impl Query
sourcepub fn nearest_to(self, vector: impl IntoQueryVector) -> Result<VectorQuery>
pub fn nearest_to(self, vector: impl IntoQueryVector) -> Result<VectorQuery>
Find the nearest vectors to the given query vector.
This converts the query from a plain query to a vector query.
This method will attempt to convert the input to the query vector expected by the embedding model. If the input cannot be converted then an error will be returned.
By default, there is no embedding model, and the input should be vector/slice of floats.
If there is only one vector column (a column whose data type is a
fixed size list of floats) then the column does not need to be specified.
If there is more than one vector column you must use [Query::column
]
to specify which column you would like to compare with.
If no index has been created on the vector column then a vector query will perform a distance comparison between the query vector and every vector in the database and then sort the results. This is sometimes called a “flat search”
For small databases, with a few hundred thousand vectors or less, this can be reasonably fast. In larger databases you should create a vector index on the column. If there is a vector index then an “approximate” nearest neighbor search (frequently called an ANN search) will be performed. This search is much faster, but the results will be approximate.
The query can be further parameterized using the returned builder. There are various search parameters that will let you fine tune your recall accuracy vs search latency.
§Arguments
vector
- The vector that will be used for search.
Trait Implementations§
source§impl ExecutableQuery for Query
impl ExecutableQuery for Query
source§async fn execute_with_options(
&self,
options: QueryExecutionOptions
) -> Result<SendableRecordBatchStream>
async fn execute_with_options( &self, options: QueryExecutionOptions ) -> Result<SendableRecordBatchStream>
Auto Trait Implementations§
impl Freeze for Query
impl !RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl !UnwindSafe for Query
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
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>
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 more