For eight weeks, every cMovie query has run the same on Astra DB and Apache Cassandra® 5.0. That’s on purpose, because the series sticks to what both support. Step outside that shared subset and the answers start to differ. For example, here is a query that asks for movies from 1994 or 1999, run on Astra DB:
SELECT title, release_year FROM movies WHERE release_year = 1994 OR release_year = 1999 LIMIT 10;
title | release_year
------------------------------------+--------------
Ed Wood | 1994
South Park: Bigger, Longer & Uncut | 1999
Chungking Express | 1994
American Beauty | 1999
Cruel Intentions | 1999
The Ninth Gate | 1999
All About My Mother | 1999
The Insider | 1999
Anna and the King | 1999
Dogma | 1999
(10 rows)
The same statement on Cassandra 5.0.9 doesn’t even parse:
SELECT title, release_year FROM movies WHERE release_year = 1994 OR release_year = 1999 LIMIT 10;
SyntaxException: line 1:65 no viable alternative at input 'OR' (...movies WHERE release_year = 1994 [OR]...)
Same CQL, different fine print. This post walks through where Storage Attached Indexing (SAI) and vector search differ between the two, so nothing catches you out when you move a query from one to the other.
This is the ninth instalment in the Cassandra 5.0 series where I’ll show you how to build an AI movie recommender app with Python and TypeScript.
What you’ll learn and what you need
You’ll learn:
- why Astra DB and Cassandra 5.0 support different SAI and vector features,
- which queries run on Astra DB but fail on 5.0, with the error you’ll see on 5.0, and
- what’s the same on both, so you know which habits carry over.
This post is a bit different from the others. Every other week teaches only what Cassandra 5.0 can do, and Astra DB is just where we run it. This week is about the gap between them, so some of the queries below are Astra DB only, and each one shows what 5.0 says instead.
We’ll continue to use the same Astra DB database and the cMovie movies table from earlier weeks, with every plot embedded and the vector index built. The 5.0 results come from the released cassandra:5.0 Docker image (5.0.9) loaded with the same movies.
For full disclosure, I’m an Apache Cassandra committer and a Developer Advocate at DataStax, now an IBM company. We’re using Astra DB for convenience so you can focus on building apps as a developer without worrying about how to install or configure a cluster, but every 5.0 result in this post was run on Cassandra 5.0.9.
You can run the Astra DB queries in the Astra CQL console. If your database has been idle for a while, check that it isn’t hibernated first. Section 2.4 of the setup page shows how.
Why they differ
SAI didn’t start in Apache Cassandra. DataStax built it for Astra DB, then donated it to the Apache project through CEP-7, the Cassandra Enhancement Proposal for SAI. Cassandra 5.0 ships the first phase of that work. Astra DB kept building in the meantime, so it’s further along the same roadmap, not on a different one.
Vector search follows the same pattern. Both use JVector, the vector search library Jonathan Ellis created. Cassandra 5.0 pins JVector 1.0.2. Astra DB runs builds of DataStax’s Cassandra fork, and those builds use JVector 4.
The two aren’t at parity yet, but they’re heading the same way. For example, moving Apache Cassandra to JVector 4 is tracked in CASSANDRA-21064, planned for a future release.
The differences at a glance
This table lists only the areas where the two differ. The sections after it show each one on the cMovie table.
| Area | Cassandra 5.0 | Astra DB |
|---|---|---|
| Index syntax | USING 'sai' or CREATE CUSTOM INDEX. A plain CREATE INDEX gives a legacy index | CREATE CUSTOM INDEX only. A plain CREATE INDEX gives SAI |
| Query operators | =, ranges, AND and CONTAINS. IN needs ALLOW FILTERING. No OR, != or NOT IN | Adds OR, IN, != and NOT IN, also alongside ANN OF |
| Sorting | ORDER BY only for ANN OF | ORDER BY on indexed columns |
| Text search | Whole-value matching only | Lucene analysers and the : operator |
| Vector production status | Experimental warning | Generally available |
| Vector index tuning | similarity_function and optimize_for. Graph options are gated behind a system property | Adds source_model presets and the latest JVector graph options |
| Index limits | None | 10 per table, 100 per database |
| Server-side embedding, hybrid search and reranking | None | Data API |
SAI differences on the cMovie table
As they say, on with the show. Every query in this section runs on Astra DB, and each one is followed by what 5.0.9 does with it.
OR and IN
You saw OR in the opening example. Astra DB also accepts OR across different columns and on collection columns, such as genres CONTAINS 'drama' OR genres CONTAINS 'black comedy'. Cassandra 5.0 rejects all of them with the same SyntaxException, because the 5.0 CQL grammar has no OR in a WHERE clause.
IN is closer. Here it is on Astra DB, where it returns the same 10 movies as the OR query:
SELECT title, release_year FROM movies WHERE release_year IN (1994, 1999) LIMIT 10;
title | release_year
------------------------------------+--------------
Ed Wood | 1994
South Park: Bigger, Longer & Uncut | 1999
Chungking Express | 1994
American Beauty | 1999
Cruel Intentions | 1999
The Ninth Gate | 1999
All About My Mother | 1999
The Insider | 1999
Anna and the King | 1999
Dogma | 1999
(10 rows)
On 5.0.9 the same statement asks for ALLOW FILTERING:
SELECT title, release_year FROM movies WHERE release_year IN (1994, 1999) LIMIT 10;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING"
Adding ALLOW FILTERING makes 5.0.9 return the same 10 movies. It works, but the name is a warning in itself: Cassandra may read far more rows than it returns. On 5.0, run two = queries instead and merge the results in your app.
!= and NOT IN
Astra DB also handles exclusions. Here are five movies not from 1994:
SELECT title, release_year FROM movies WHERE release_year != 1994 LIMIT 5;
title | release_year
-------------------------------------------+--------------
Three Billboards Outside Ebbing, Missouri | 2017
X-Men Origins: Wolverine | 2009
Mad Max: Fury Road | 2015
Meet Joe Black | 1998
The Social Network | 2010
(5 rows)
Cassandra 5.0.9 rejects != outright:
SELECT title, release_year FROM movies WHERE release_year != 1994 LIMIT 5;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Unsupported "!=" relation: release_year != 1994"
NOT IN (1994, 1999) behaves the same way: Astra DB returns rows, and 5.0.9 gives a SyntaxException at NOT.
ORDER BY on an indexed column
On 5.0, the only ORDER BY an SAI query accepts is ANN OF. Astra DB also sorts by an ordinary indexed column. Here are the newest dramas, sorted by release_year:
SELECT title, release_year FROM movies WHERE genres CONTAINS 'drama' ORDER BY release_year DESC LIMIT 5;
title | release_year
-------------------------+--------------
Disclosure Day | 2026
Michael | 2026
The Devil Wears Prada 2 | 2026
Wuthering Heights | 2026
Mickey 17 | 2025
(5 rows)
Warnings :
Top-K queries can only be run with consistency level ONE / LOCAL_ONE / NODE_LOCAL. Consistency level LOCAL_QUORUM was requested. Downgrading the consistency level to LOCAL_ONE.
The warning is the one from week 5. Astra DB treats a sorted SAI query as a “top K” query, the same kind as a vector search, so it runs at LOCAL_ONE and says so.
On 5.0.9 the query is rejected:
SELECT title, release_year FROM movies WHERE genres CONTAINS 'drama' ORDER BY release_year DESC LIMIT 5;
InvalidRequest: Error from server: code=2200 [Invalid query] message="ORDER BY with 2ndary indexes is not supported, except for ANN queries."
On 5.0 you’ll need to fetch the rows and sort them in your app, the same way week 8 applied its score threshold in TypeScript.
Keyword search inside plots
In week 2, searching titles meant matching whole values, so we split each title into words in a separate column. Astra DB can split text for you. An SAI index with an index_analyzer option runs the text through a Lucene analyser, which breaks it into words, and the : operator matches a word inside the column.
Let’s add one to the plot column on Astra DB:
CREATE CUSTOM INDEX movies_plot_analysed_idx ON movies (plot) USING 'StorageAttachedIndex' WITH OPTIONS = {'index_analyzer': 'standard'};
Give the index a minute to build. If you query too soon, you’ll get an INDEX_BUILD_IN_PROGRESS failure. Once it’s ready, here are five movies whose plot mentions a heist:
SELECT title FROM movies WHERE plot : 'heist' LIMIT 5;
title
--------------------------
Minions: The Rise of Gru
Snatch
Red Notice
Heat
Ocean's Eleven
(5 rows)
Combine two words with AND to narrow it to heists that involve a bank:
SELECT title FROM movies WHERE plot : 'heist' AND plot : 'bank' LIMIT 5;
title
--------------------------
Minions: The Rise of Gru
Heat
Now You See Me
(3 rows)
On 5.0.9 the index itself fails, because 5.0’s SAI doesn’t know the option:
CREATE CUSTOM INDEX movies_plot_analysed_idx ON movies (plot) USING 'StorageAttachedIndex' WITH OPTIONS = {'index_analyzer': 'standard'};
ConfigurationException: Properties specified [index_analyzer] are not understood by StorageAttachedIndex
The : operator is a SyntaxException on 5.0.9 too. For keyword matching on 5.0, the week 2 approach of a set of words with CONTAINS is the way to go.
As a side note, Astra DB still accepts = on an analysed column and returns the same five heist movies, but it prints a warning recommending : instead and says future versions will remove = on analysed indexes. I recommend : from the start.
The next section uses this index once more, so keep it for now.
Info
The plain
CREATE INDEXgives you different indexes. On Cassandra 5.0,CREATE INDEX ... USING 'sai'creates an SAI index, and a plainCREATE INDEXwith noUSINGcreates a legacy secondary index, the older kind that SAI replaces. On Astra DB,USING 'sai'fails withCannot specify index class for a non-CUSTOM index, and a plainCREATE INDEXcreates an SAI index. If you want one statement that does the same thing on both, useCREATE CUSTOM INDEX ... USING 'StorageAttachedIndex', as this series has from the start.
Vector search differences
Experimental on 5.0, generally available on Astra DB
When you create a vector index on Cassandra 5.0.9, it prints this warning:
CREATE CUSTOM INDEX movies_plot_embedding_idx ON movies (plot_embedding) USING 'StorageAttachedIndex' WITH OPTIONS = {'similarity_function': 'COSINE'};
Warnings :
SAI ANN indexes on vector columns are experimental and are not recommended for production use.
They don't yet support SELECT queries with:
* Consistency level higher than ONE/LOCAL_ONE.
* Paging.
* No LIMIT clauses.
* PER PARTITION LIMIT clauses.
* GROUP BY clauses.
* Aggregation functions.
* Filters on columns without a SAI index.
Astra DB prints no warning, and vector search there is generally available. That’s the reason the callout in weeks 3 and 5 pointed here. Note that the restrictions in the list still apply on Astra DB, as the “What’s the same” section below shows. Only the experimental label is different.
Index options
Both accept similarity_function, which week 7 covered, and optimize_for. Beyond those two, Astra DB accepts several more options that tune how the vector index is built:
-- Accepted by Astra DB, each on its own in WITH OPTIONS
'source_model': 'openai_v3_large'
'enable_hierarchy': 'true'
'neighborhood_overflow': '1.2'
'alpha': '1.2'
'maximum_node_connections': '32'
'construction_beam_width': '200'
Cassandra 5.0.9 rejects the first four as unknown, for example:
CREATE CUSTOM INDEX vec_opts_idx ON vec_opts (v) USING 'StorageAttachedIndex' WITH OPTIONS = {'source_model': 'openai_v3_large'};
ConfigurationException: Properties specified [source_model] are not understood by StorageAttachedIndex
The last two exist in 5.0, but they’re switched off unless the node is started with a system property:
CREATE CUSTOM INDEX vec_opts_idx ON vec_opts (v) USING 'StorageAttachedIndex' WITH OPTIONS = {'maximum_node_connections': '32'};
InvalidRequest: Error from server: code=2200 [Invalid query] message="Maximum node connections cannot be set without enabling SAI_VECTOR_ALLOW_CUSTOM_PARAMETERS"
One caution. “Accepted” means Astra DB stored the option without an error. It doesn’t prove what the option changes inside the index, and I didn’t measure that. The options exist because JVector 4 has features JVector 1.0.2 doesn’t.
JVector 1 and JVector 4 in plain terms
Here’s what those newer features mean for you as a developer. The left column says what JVector 4 supports.
| JVector 4 | JVector 1.0.2 (Cassandra 5.0) | Why a developer cares |
|---|---|---|
Supports compression tuned to each embedding model, chosen with source_model | One fixed compression for every model | The same memory holds more vectors |
| Supports building indexes larger than memory | Each index graph is built in memory | Large vector tables are less limited by memory. Jonathan Ellis describes this in Indexing all of Wikipedia, on a laptop |
Optional layered graph (enable_hierarchy) and exposed tuning options | A single-layer graph with fixed settings | More control over the trade-off between speed and accuracy |
| Supports removing deleted vectors from the index | Deleted vectors stay and are filtered out at search time | Tables with lots of updates cost 5.0 more work per search |
Keywords and vectors in one query
The analysed plot index opens up something 5.0 can’t do in CQL: a keyword filter and a vector search in the same statement. This query finds the movies closest to Her (2013), but only among plots that mention love. The vector bound to ? is Her’s own plot_embedding, read from the table first, as in week 8:
SELECT title FROM movies WHERE plot : 'love' ORDER BY plot_embedding ANN OF ? LIMIT 5;
title
---------------------------------------
Her
Sleepless in Seattle
500 Days of Summer
Eternal Sunshine of the Spotless Mind
Up in the Air
(5 rows)
Compared to the same search with no keyword filter, Ex Machina drops out and Up in the Air comes in, because only plots that contain the word “love” are searched. On 5.0 you’ll need to do this in two steps in your app: a vector search for more rows than you need, then a keyword check on each plot.
OR works alongside ANN OF on Astra DB too. WHERE release_year = 1994 OR release_year = 2013 with the same vector returns Her, Chungking Express, Oblivion, Léon: The Professional and Four Weddings and a Funeral. On 5.0.9 it’s the same OR syntax error as before.
That’s the last use of the analysed index, so let’s drop it and put the table back how it was:
DROP INDEX movies_plot_analysed_idx;
What’s the same on both
The fine print isn’t all different. Several rules you met in earlier weeks hold on both, so your habits carry over.
LIMIT: A vector query needs aLIMIT, and theLIMITcan’t be more than 1,000. Both rejectLIMIT 1001, with slightly different wording: Astra DB says “SAI based ORDER BY clause requires a LIMIT that is not greater than 1000”, and 5.0.9 says “Use of ANN OF in an ORDER BY clause requires a LIMIT that is not greater than 1000”.- Consistency: Both quietly downgrade a vector query’s consistency level to
LOCAL_ONEand print the same warning. - Filters: A filter next to
ANN OFmust be on an indexed column on both, even withALLOW FILTERING, socmovie_votes > 100fails on each. LIKE: Both reject it.- Scores:
similarity_cosinegives the same scores on each: Her scores 1.0 against itself, Sleepless in Seattle 0.8577 and 500 Days of Summer 0.8572.
Limits and guardrails
Astra DB sets limits that 5.0 doesn’t. They’re opinionated, chosen so a database stays fast. Here’s the 11th SAI index on one Astra DB table:
CREATE CUSTOM INDEX quota_c11_idx ON quota (c11) USING 'StorageAttachedIndex';
InvalidRequest: Error from server: code=2200 [Invalid query] message="Tables cannot have more than 10 StorageAttachedIndex secondary indexes, failed to create secondary index quota_c11_idx on table quota"
The same 11th index on 5.0.9 succeeds, and so does a 12th. Astra DB also limits a database to 100 indexes and a table to 75 columns, as listed on its database limits page.
Cassandra 5.0 doesn’t enforce these, but I recommend treating them as good production targets anyway. Every index is work done on every write. On 5.0 the equivalent controls are guardrails in cassandra.yaml, which whoever runs the cluster sets and tunes.
A teaser: the Data API
Some Astra DB features have no CQL form at all. Astra DB’s Data API can embed your text on the server with $vectorize, so your app doesn’t call an embedding model itself. It also does keyword search with $lexical, combines keyword and vector search in one request with $hybrid, and reranks results with a find-and-rerank command. Cassandra 5.0 has none of these. A tutorial series on the Data API is coming soon.
Recap
- SAI and vector search started in Astra DB. Cassandra 5.0 ships the first phase, and Astra DB is further down the same roadmap.
- Astra DB supports
OR,!=,NOT IN,INwithoutALLOW FILTERING,ORDER BYon indexed columns and analysed text with:. Cassandra 5.0 doesn’t. - Vector indexes are experimental in 5.0 and generally available on Astra DB, which runs JVector 4 against 5.0’s JVector 1.0.2.
- The
LIMITrules, the consistency downgrade, the indexed-filter rule and the similarity scores are the same on both. - For one statement that works on both, use
CREATE CUSTOM INDEX ... USING 'StorageAttachedIndex'.
Next week, we finish the series by ranking vector search results in TypeScript, blending similarity with rating and popularity. It’s in week 10.
Try one of your own queries from earlier weeks with an OR or an ORDER BY on Astra DB, and see what it gives you. If you want next week’s post when it lands, follow me using the social buttons on the 8567.me homepage.
Movie facts from Wikidata, CC0. Plot text is fetched by the loader from each movie’s English Wikipedia article, CC BY-SA 4.0, and the wikipedia_url column links to each article.
Apache Cassandra, Cassandra, Apache, the Apache logo, and the Apache Cassandra project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
