Skip to content

vector-store: allow syntax for local indexes#362

Open
ewienik wants to merge 7 commits intoscylladb:masterfrom
ewienik:vector-531-local-indexes-as-global
Open

vector-store: allow syntax for local indexes#362
ewienik wants to merge 7 commits intoscylladb:masterfrom
ewienik:vector-531-local-indexes-as-global

Conversation

@ewienik
Copy link
Collaborator

@ewienik ewienik commented Feb 9, 2026

ScylladDB currently supports syntax for creating local indexes. Vector-store needs to be able to read them and create local indexes using specified primary key. There will be several PRs to introduce full local indexes. This PR parses local indexes metadata and creates local indexes as global indexes.

The change introduces parsing and testing local indexes and refactoring of tests and types.

Fixes: vector-531

@ewienik
Copy link
Collaborator Author

ewienik commented Feb 9, 2026

Changelog for 1fd0207

  • fix clippy warning
range diff
1:  cdc881af ! 1:  02bc1860 vector-store/tests: use DbIndexType in integration tests
    @@ crates/vector-store/tests/integration/usearch.rs: pub(crate) async fn setup_stor
              index_name: "ann".into(),
              target_column: "embedding".into(),
     +        index_type,
    -+        filtering_columns: columns.iter().map(|(name, _)| name.clone()).collect(),
    ++        filtering_columns: columns.keys().cloned().collect(),
              dimensions: dimension,
     -        index_type: DbIndexType::Global,
     -        filtering_columns: vec![],
2:  c0f1b763 = 2:  e3043edd vector-store: refactor AsRef trait for *Name types
3:  4b9e659d = 3:  d5e72d43 validator: refactor keyspace/table/index names
4:  2b226301 = 4:  8a07e0eb validator: refactor create_index with CreateIndexQuery
5:  deb33596 = 5:  e1ef607e validator: implement support for local indexes in CreateIndexQuery
6:  15dcaa77 = 6:  1fd0207b validator: implement index_create test case

@ewienik ewienik force-pushed the vector-531-local-indexes-as-global branch from 15dcaa7 to 1fd0207 Compare February 9, 2026 12:58
vector-store must support local indexes cql metadata for vector search. This
commit adds DbIndexType enum to distinguish between global and local indexes.
It will be needed in further PRs for implementing fully local indexes.

The commit implements additional field for IndexMetadata: additional filtering
columns. This field will be needed in future PR to retrieve data for these
columns and allow filtering on their values.

The commit parses index options target to distinguish between local or global
indexes.

Fixes: VECTOR-531
This commit updates integration tests setup_store with ability to set
index type during integration tests.
For easier usage of KeyspaceName, TableName, ColumnName, IndexName this commit
provides AsRef<str> for them.
In validator tests common functions for creating unique names used uuid. This
commit uses atomic counters to provide shorter unique names, easier for
investigating logs.
Validator needs common way to create different version of indexes -
with/without specific options, with/without filtering columns. This commit
introduces CreateIndexQuery struct to provide builder for such index -
different optional parameters could be setup using piping methods.

The commit refactors create_index to support CreateIndexQuery as a parameter.
To be able to support syntax for local index create the commit adds additional
method and field to the CreateIndexQuery to support creating local primary key
for an index.
The commit adds four tests in index_create testcase. Two for global indexes and
two for local indexes, with or without additional filtering columns. The test
constains index creation and simple query for the index.

The query test for global index with filtering columns is disabled, because it
is failing.  SCYLLADB-635 bug is prepared to fix it.
@ewienik
Copy link
Collaborator Author

ewienik commented Feb 12, 2026

Changelog for 81bb2df

  • provide local partition key's columns within DbIndexType::Local
range diff
1:  ec8a85f2 ! 1:  4a4dd003 vector-store: implement local indexes as global indexes
    @@ crates/vector-store/src/db.rs: impl Statements {
     +
     +        let mut columns = target_option.ck.into_iter();
     +        return Ok((
    -+            DbIndexType::Local,
    ++            DbIndexType::Local(target_option.pk.into_iter().map(ColumnName::from).collect()),
     +            columns.next().unwrap().into(),
     +            columns.map(ColumnName::from).collect(),
     +        ));
    @@ crates/vector-store/src/db.rs: impl Statements {
     +    let target_name = target_option.pk.remove(0);
     +    validate_target_type(&target_name)?;
     +    Ok((
    -+        DbIndexType::Local,
    ++        DbIndexType::Global,
     +        target_name.into(),
     +        target_option.ck.into_iter().map(ColumnName::from).collect(),
     +    ))
    @@ crates/vector-store/src/lib.rs: impl IndexMetadata {
          }
      }
      
    -+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
    ++#[derive(Clone, Debug, PartialEq, Eq, Hash)]
     +pub enum DbIndexType {
     +    Global,
    -+    Local,
    ++    Local(Vec<ColumnName>),
     +}
     +
      #[derive(Debug)]
2:  02bc1860 = 2:  f4c9e7fa vector-store/tests: use DbIndexType in integration tests
3:  e3043edd = 3:  7a881921 vector-store: refactor AsRef trait for *Name types
4:  d5e72d43 = 4:  1bb77bd9 validator: refactor keyspace/table/index names
5:  8a07e0eb = 5:  923d2262 validator: refactor create_index with CreateIndexQuery
6:  e1ef607e = 6:  55ec8a11 validator: implement support for local indexes in CreateIndexQuery
7:  1fd0207b = 7:  81bb2df7 validator: implement index_create test case

@ewienik ewienik force-pushed the vector-531-local-indexes-as-global branch from 1fd0207 to 81bb2df Compare February 12, 2026 12:22
Copy link
Collaborator

@knowack1 knowack1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look great. Please check some of my nit thoughts/comments. I would consider unit tests for a new code in db.rs - the logic looks quite complex there.

ck: Vec<String>,
}

fn from_target_option(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have unit tests for this logic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is impossible to unit test this as the function uses cql driver's Table struct which we cannot prepare manually (it needs working session with db)

common::wait_for_index(client, &index).await;
}

// TODO: Re-enable this test after SCYLLADB-635 is solved.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be good to have an jira issue for this. Otherwise we will forget.

.await;

info!("Wait for the index to be created");
for client in &clients {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider encapsulating this loop into a function - also in other places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants