Search code examples
indexingcassandracassandra-4.0

Can I create Storage Attached Indexes on a map's values in Cassandra 4.x?


Is it be possible to create a Storage Attached Index on a map's values in Cassandra? In my case, I have a column named coordinates which is of data type map<text,float> and contains latitude and longitude of the sensors' locations. I would therefore like to create a SAI on the map's values so to be able to query the table based on those values.

Is this an anti-pattern? Would it be better to have two separate columns for latitude and longitude?


Solution

  • No, creating a SASI Index is not supported on a map (or other "complex" types) yet.

    Is this an anti-pattern?

    Unfortunately yes. Even if it worked, filtering in the WHERE clause by coordinates alone would not be a partition-based query, and would be a bit slow. Not sure how the key is/was modeled here, but there would need to be some work done to ensure that a query could be served by a single node. And SAI/SASI based index queries can't guarantee that.