You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Li Tao <ah...@gmail.com> on 2015/12/06 04:47:45 UTC

Re: Nested Collections in Cassandra

how about saving it as blob type?
On Nov 16, 2015 12:18 AM, "Neha Dave" <ne...@gmail.com> wrote:

> Hi Jack,
> Thanks for the response.
>
> Do you think it's a good idea to have a separate table like :
>
> CREATE TYPE metadata (
>       key text,
>       value set<text>,
>       path_id uuid
>   );
>
> And then index it on Value so that the query like... :
> SELECT * from metadata where value CONTAINS {values: {'FOX'};
>
> 2. Can I use composite column? any idea?
>
> regards
> neha
>
>
>
>
> On Sat, Nov 14, 2015 at 9:21 PM, Jack Krupansky <ja...@gmail.com>
> wrote:
>
>> 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 <ne...@gmail.com>
>> wrote:
>>
>>> Any Help?
>>>
>>> On Tue, Nov 10, 2015 at 7:44 PM, Neha Dave <ne...@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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>