'How to query a field in cassandra under a Map with Userdefined values?

Let's say I have a table in some keyspace in cassandra like this, because I want to store different versions of the same data as a user defined type (like different descriptions in this case)

example description data:

{
 "digest" : "abc123",
 "text" : "An awfully long description that is not needed on every request"
}
CREATE TYPE test_keyspace.description (
    digest text,
    text text
);

CREATE TABLE test_keyspace.my_table (
    pk text PRIMARY KEY,
    description map<text, frozen<description>>,
);

The my_table contains a map where the versions are the keys and the different description objects are the values.

I need to have the text and the digest available in the database, but sometimes I want to only retrieve the digest values (for all keys in the map) for a given pk, since the full text can be very big and I want to save some time/data on transmission when possible. Is it even possible in cassandra to construct such a SELECT statement?

Any help is appreciated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source