feat: support to build FTS without positions (#1621)

This commit is contained in:
BubbleCal
2024-09-10 22:51:32 +08:00
committed by GitHub
parent a405847f9b
commit 2bde5401eb
11 changed files with 150 additions and 25 deletions

View File

@@ -14,6 +14,7 @@
use std::sync::Mutex;
use lancedb::index::scalar::FtsIndexBuilder;
use lancedb::{
index::{scalar::BTreeIndexBuilder, vector::IvfPqIndexBuilder, Index as LanceDbIndex},
DistanceType,
@@ -100,10 +101,14 @@ impl Index {
}
#[staticmethod]
pub fn fts() -> PyResult<Self> {
Ok(Self {
inner: Mutex::new(Some(LanceDbIndex::FTS(Default::default()))),
})
pub fn fts(with_position: Option<bool>) -> Self {
let mut opts = FtsIndexBuilder::default();
if let Some(with_position) = with_position {
opts = opts.with_position(with_position);
}
Self {
inner: Mutex::new(Some(LanceDbIndex::FTS(opts))),
}
}
}