Is it possible to query items in a CQL table that exactly match a specific element in a set. For example, can we search for where tag="music"
on the following table?
create table if not exists example (
website text,
uuid text,
message text,
tags set<text>,
created timestamp,
primary key ((site), uuid))
It's possible to search for elements in the collection using the CONTAINS
operator (see documentation). But it will be very slow, so index on collection may help (see docs for syntax) but it's also not necessary optimal. Better solution would be something like Storage Attached Indexes from DataStax, but they aren't in the OSS Cassandra yet. Another solution could be integration of real search engine, like, Solr (known as DSE Search), or Elasticsearch (as in Elassandra).
The main thing to take into account would be to analyze the latency requirements, in some cases, it would be better to have a separate table with tag as partition key, but in this case you may have data skew as there are not so many tags, and distribution of data is not uniform.