mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-03 10:22:56 +00:00
Compare commits
2 Commits
python-v0.
...
2629-node-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8f57e8043 | ||
|
|
c36409d3b8 |
@@ -363,6 +363,23 @@ export class StandardQueryBase<
|
|||||||
return this.where(predicate);
|
return this.where(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable autoprojection of scoring columns.
|
||||||
|
*
|
||||||
|
* When you specify an explicit projection with {@link select} that does not
|
||||||
|
* include scoring columns (e.g. `_score` for FTS or `_distance` for vector
|
||||||
|
* search), Lance currently auto-includes those columns and emits a
|
||||||
|
* deprecation warning. Calling this method disables that behavior so the
|
||||||
|
* scoring columns are only returned if explicitly selected.
|
||||||
|
*/
|
||||||
|
disableScoringAutoprojection(): this {
|
||||||
|
this.doCall((inner: NativeQueryType) => {
|
||||||
|
// @ts-expect-error method is present on Query and VectorQuery only
|
||||||
|
inner.disableScoringAutoprojection();
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
fullTextSearch(
|
fullTextSearch(
|
||||||
query: string | FullTextQuery,
|
query: string | FullTextQuery,
|
||||||
options?: Partial<FullTextSearchOptions>,
|
options?: Partial<FullTextSearchOptions>,
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ impl Query {
|
|||||||
self.inner = self.inner.clone().with_row_id();
|
self.inner = self.inner.clone().with_row_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[napi]
|
||||||
|
pub fn disable_scoring_autoprojection(&mut self) {
|
||||||
|
self.inner = self.inner.clone().disable_scoring_autoprojection();
|
||||||
|
}
|
||||||
|
|
||||||
#[napi(catch_unwind)]
|
#[napi(catch_unwind)]
|
||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
@@ -265,6 +270,11 @@ impl VectorQuery {
|
|||||||
self.inner = self.inner.clone().with_row_id();
|
self.inner = self.inner.clone().with_row_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[napi]
|
||||||
|
pub fn disable_scoring_autoprojection(&mut self) {
|
||||||
|
self.inner = self.inner.clone().disable_scoring_autoprojection();
|
||||||
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn rerank(&mut self, callbacks: RerankerCallbacks) {
|
pub fn rerank(&mut self, callbacks: RerankerCallbacks) {
|
||||||
self.inner = self
|
self.inner = self
|
||||||
|
|||||||
@@ -448,6 +448,15 @@ pub trait QueryBase {
|
|||||||
/// the scores are converted to ranks and then normalized. If "Score", the
|
/// the scores are converted to ranks and then normalized. If "Score", the
|
||||||
/// scores are normalized directly.
|
/// scores are normalized directly.
|
||||||
fn norm(self, norm: NormalizeMethod) -> Self;
|
fn norm(self, norm: NormalizeMethod) -> Self;
|
||||||
|
|
||||||
|
/// Disable autoprojection of scoring columns.
|
||||||
|
///
|
||||||
|
/// When an explicit projection is provided that does not include scoring
|
||||||
|
/// columns (e.g. `_score` for FTS or `_distance` for vector search), the
|
||||||
|
/// current default behavior is to auto-include those columns and emit a
|
||||||
|
/// deprecation warning. Calling this adopts the future behavior and avoids
|
||||||
|
/// the warning.
|
||||||
|
fn disable_scoring_autoprojection(self) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HasQuery {
|
pub trait HasQuery {
|
||||||
@@ -507,6 +516,11 @@ impl<T: HasQuery> QueryBase for T {
|
|||||||
self.mut_query().norm = Some(norm);
|
self.mut_query().norm = Some(norm);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn disable_scoring_autoprojection(mut self) -> Self {
|
||||||
|
self.mut_query().disable_scoring_autoprojection = true;
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Options for controlling the execution of a query
|
/// Options for controlling the execution of a query
|
||||||
@@ -645,6 +659,10 @@ pub struct QueryRequest {
|
|||||||
|
|
||||||
/// Configure how query results are normalized when doing hybrid search
|
/// Configure how query results are normalized when doing hybrid search
|
||||||
pub norm: Option<NormalizeMethod>,
|
pub norm: Option<NormalizeMethod>,
|
||||||
|
|
||||||
|
/// If true, do not auto-include scoring columns when they are
|
||||||
|
/// omitted from an explicit projection.
|
||||||
|
pub disable_scoring_autoprojection: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for QueryRequest {
|
impl Default for QueryRequest {
|
||||||
@@ -660,6 +678,7 @@ impl Default for QueryRequest {
|
|||||||
prefilter: true,
|
prefilter: true,
|
||||||
reranker: None,
|
reranker: None,
|
||||||
norm: None,
|
norm: None,
|
||||||
|
disable_scoring_autoprojection: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -372,6 +372,9 @@ impl<S: HttpSend> RemoteTable<S> {
|
|||||||
params: &QueryRequest,
|
params: &QueryRequest,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
body["prefilter"] = params.prefilter.into();
|
body["prefilter"] = params.prefilter.into();
|
||||||
|
if params.disable_scoring_autoprojection {
|
||||||
|
body["disable_scoring_autoprojection"] = serde_json::Value::Bool(true);
|
||||||
|
}
|
||||||
if let Some(offset) = params.offset {
|
if let Some(offset) = params.offset {
|
||||||
body["offset"] = serde_json::Value::Number(serde_json::Number::from(offset));
|
body["offset"] = serde_json::Value::Number(serde_json::Number::from(offset));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2331,6 +2331,10 @@ impl BaseTable for NativeTable {
|
|||||||
scanner.full_text_search(fts.clone())?;
|
scanner.full_text_search(fts.clone())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if query.base.disable_scoring_autoprojection {
|
||||||
|
scanner.disable_scoring_autoprojection();
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(refine_factor) = query.refine_factor {
|
if let Some(refine_factor) = query.refine_factor {
|
||||||
scanner.refine(refine_factor);
|
scanner.refine(refine_factor);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user