Skip to content

Commit 9c972c2

Browse files
authored
fix: optimizing FTS causes error if it's without positions (#4044)
Signed-off-by: BubbleCal <bubble-cal@outlook.com>
1 parent 8b6ee90 commit 9c972c2

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

rust/lance-index/src/scalar/inverted/index.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,11 @@ impl InvertedPartition {
573573
builder
574574
.posting_lists
575575
.reserve_exact(self.inverted_list.len());
576-
for posting_list in self.inverted_list.read_all(true).await? {
576+
for posting_list in self
577+
.inverted_list
578+
.read_all(self.inverted_list.has_positions())
579+
.await?
580+
{
577581
let posting_list = posting_list?;
578582
builder
579583
.posting_lists

rust/lance/src/index.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ mod tests {
13241324
use lance_io::object_store::ObjectStoreParams;
13251325
use lance_linalg::distance::{DistanceType, MetricType};
13261326
use lance_testing::datagen::generate_random_array;
1327+
use rstest::rstest;
13271328
use std::collections::HashSet;
13281329
use tempfile::tempdir;
13291330

@@ -1789,8 +1790,9 @@ mod tests {
17891790
assert_eq!(stats["num_indices"], 1);
17901791
}
17911792

1793+
#[rstest]
17921794
#[tokio::test]
1793-
async fn test_optimize_fts() {
1795+
async fn test_optimize_fts(#[values(false, true)] with_position: bool) {
17941796
let words = ["apple", "banana", "cherry", "date"];
17951797

17961798
let dir = tempdir().unwrap();
@@ -1805,7 +1807,7 @@ mod tests {
18051807

18061808
let params = InvertedIndexParams::default()
18071809
.lower_case(false)
1808-
.with_position(true);
1810+
.with_position(with_position);
18091811
dataset
18101812
.create_index(&["text"], IndexType::Inverted, None, &params, true)
18111813
.await

0 commit comments

Comments
 (0)