how to filter cassandra query by user defined type field? i want to create people table in my cassandra database so i create this user-defined-type in my cassandra database.
create type fullname ( firstname text, lastname text );
and i have this table too.
create table people ( id UUID primary key, name frozen <fullname> );
and i need to filter my query to know all people with lastname jolie. how can i query this from this table. and totally how is filtering and query in cassandra? I know i can delete fullname type and add firstname and lastname to main table but it is a sample of what i want to do.i must have fullname type.
Short answer: you can use secondary indexes to query by fullname UDT. But you cannot query by only a part of your UDT.
The reason for such behaviour is a way C* secondary indexes are implemented. In general, it's just another hidden table maintained by C*, in your case defined as:
Actually your secondary and primary keys are swapped in this table. So your case is reduced to a more general question 'why can't I query by only a part of PK?':
Suggested solutions: