Indexing and querying user-defined types

Like tuple columns, columns with user-defined types can be indexed and queried. Let's add an index to our new education column:

CREATE INDEX ON "users" ("education"); 

Now we can query for a given value of education keeping in mind that just as with a tuple, we must specify the full value of the user-defined type, with all fields:

SELECT "username", "education" FROM "users" WHERE "education" = {   "school_name": 'Big Data University',   "graduation_year": 2003 }; 

As expected, the result consists of the alice row, which contains the exact value we specified in her education column:

Get Learning Apache Cassandra - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.