cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack Krupansky <jack.krupan...@gmail.com>
Subject Re: Nested Collections in Cassandra
Date Sat, 14 Nov 2015 15:51:35 GMT
You can only nest frozen collections and even then you can only access the
full nested value, not individual entries within the nested map.

So, in your example, you can only access mimetype and then must specify the
full mime type value, which doesn't satisfy your query requirement.

You will need to flatten your nesting into distinct rows with clustering
keys. Then you can query a row with the mimetype in a clustering key. And
add a clustering key for the mime values name.

-- Jack Krupansky

On Sat, Nov 14, 2015 at 5:16 AM, Neha Dave <nehajtrivedi@gmail.com> wrote:

> Any Help?
>
> On Tue, Nov 10, 2015 at 7:44 PM, Neha Dave <nehajtrivedi@gmail.com> wrote:
>
>> How can we achieve Nested Collections in cassandra.
>>
>> My requirement :
>> metadata map<text,list<text>> ... Is it possible?
>>
>> Eg. 'mime-type' : 'MIME'
>>       'Security'  : {'SOX','FOX'}
>>
>> Query will be Give me all the ID's where 'Security'  : {'SOX'} OR
>> contains 'SOX'
>>
>> Is it Possible?
>> Can I use UDT to do it?
>>
>> Eg CQL :
>>
>> CREATE TYPE security (
>>       number text,
>>       tags set<text>
>>   );
>>
>>
>> CREATE TYPE listdata (
>>       values set<text>
>>   );
>>
>>   CREATE TABLE test_path (
>>       path_id text PRIMARY KEY,
>>       metadata map<text, frozen<listdata>>
>>   );
>>
>> INSERT INTO test_path (path_id, metadata ) VALUES ( '2', { 'mime-type':
>> {values : {'Mime'}}
>> {'applicable-security-policy' : {'SOX','FOX'}} });
>>
>>
>> Query (which does not work) can be :
>> SELECT * from test_path where metadata CONTAINS {values: {'FOX'}, 'SOX'}}
>> ;
>> OR
>> SELECT * from test_path where metadata CONTAINS {values: {'FOX'};
>>
>>
>> Thanks
>> Regards
>> Neha
>>
>>
>>
>>
>>
>

Mime
View raw message