You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Swathi Vikas <sw...@yahoo.com> on 2012/08/16 14:39:03 UTC
wild card on query
Hi,
I am trying to run query on cassandra cluster with predicate on row key.
I have column family called "Users" and rows with row key like "projectid_userid_photos". Each user within a project can have rows like projectid_userid_blog, projectid_userid_status and so on.
I want to retrieve all the photos from all the users of certain project. My sql like query will be "select projectid * photos from Users". How can i run this kind of row key predicate while executing query on cassandra?
Any sugesstion will help.
Thank you,
swat.vikas
>>
>>
>
>
>
Re: wild card on query
Posted by Swathi Vikas <sw...@yahoo.com>.
Thank you very much Aaron. Information you provided is very helpful.
Have a great Weekend!!!
swat.vikas
________________________________
From: aaron morton <aa...@thelastpickle.com>
To: user@cassandra.apache.org
Sent: Thursday, August 16, 2012 6:29 PM
Subject: Re: wild card on query
> I want to retrieve all the photos from all the users of certain project. My sql like query will be "select projectid * photos from Users". How can i run this kind of row key predicate while executing query on cassandra?
You cannot / should not do that using the data model you have. (i.e. you could do it with a secondary index, but in this case you probably should not).
Try to de-normalise your data.
Say a CF called ProjectPhotos
* row key is the project_id
* column name is <timestamp:user_id>
* column value is image_url or JSON data about the image.
You would then slice some columns from one row in the ProjectPhotos CF.
You then need to know what images a user has uploaded, with say the UserPhotos CF.
* row key is user_id
* column name is timestamp
* column value is image_url or JSON data about the image.
I did a twitter sample app at http://wdcnz.com a couple of weeks ago that shows denormalising data https://github.com/amorton/wdcnz-2012-site and http://www.slideshare.net/aaronmorton/hellow-world-cassandra
Hope that helps.
-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com
On 17/08/2012, at 12:39 AM, Swathi Vikas <sw...@yahoo.com> wrote:
> Hi,
>
> I am trying to run query on cassandra cluster with predicate on row key.
>
> I have column family called "Users" and rows with row key like "projectid_userid_photos". Each user within a project can have rows like projectid_userid_blog, projectid_userid_status and so on.
>
> I want to retrieve all the photos from all the users of certain project. My sql like query will be "select projectid * photos from Users". How can i run this kind of row key predicate while executing query on cassandra?
>
> Any sugesstion will help.
>
> Thank you,
> swat.vikas
>>>
>>>
>>
>>
>>
>
>
>
Re: wild card on query
Posted by aaron morton <aa...@thelastpickle.com>.
> I want to retrieve all the photos from all the users of certain project. My sql like query will be "select projectid * photos from Users". How can i run this kind of row key predicate while executing query on cassandra?
You cannot / should not do that using the data model you have. (i.e. you could do it with a secondary index, but in this case you probably should not).
Try to de-normalise your data.
Say a CF called ProjectPhotos
* row key is the project_id
* column name is <timestamp:user_id>
* column value is image_url or JSON data about the image.
You would then slice some columns from one row in the ProjectPhotos CF.
You then need to know what images a user has uploaded, with say the UserPhotos CF.
* row key is user_id
* column name is timestamp
* column value is image_url or JSON data about the image.
I did a twitter sample app at http://wdcnz.com a couple of weeks ago that shows denormalising data https://github.com/amorton/wdcnz-2012-site and http://www.slideshare.net/aaronmorton/hellow-world-cassandra
Hope that helps.
-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com
On 17/08/2012, at 12:39 AM, Swathi Vikas <sw...@yahoo.com> wrote:
> Hi,
>
> I am trying to run query on cassandra cluster with predicate on row key.
>
> I have column family called "Users" and rows with row key like "projectid_userid_photos". Each user within a project can have rows like projectid_userid_blog, projectid_userid_status and so on.
>
> I want to retrieve all the photos from all the users of certain project. My sql like query will be "select projectid * photos from Users". How can i run this kind of row key predicate while executing query on cassandra?
>
> Any sugesstion will help.
>
> Thank you,
> swat.vikas
>>>
>>>
>>
>>
>>
>
>
>