Database / Apache Cassandra Intermediate and Advanced interview questions
What is SASI (SSTable Attached Secondary Index) in Cassandra?
SASI is an alternative secondary index implementation that supports query patterns the built-in 2i index cannot, most notably prefix/substring text matching and range queries on non-partition-key columns.
CREATE CUSTOM INDEX ON articles (title) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'mode': 'CONTAINS'}; SELECT * FROM articles WHERE title LIKE '%cassandra%';
- Supports
LIKEqueries (prefix, suffix, and contains modes), which standard secondary indexes cannot do at all. - Supports efficient range queries (>, <) on indexed columns, unlike the equality-only built-in index.
- Index data is stored alongside each SSTable rather than in a separate system table, hence "SSTable Attached."
SASI has long carried an experimental/unsupported label in upstream Cassandra and has known issues under heavy write and compaction load, so many teams treat it cautiously and reach for external search systems (like Elasticsearch or OpenSearch) alongside Cassandra for serious full-text search needs, using SASI only for lighter-weight range or prefix lookups.
More Related questions...