You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Arijit Mukherjee <ar...@gmail.com> on 2010/11/30 07:11:22 UTC

partial matching of keys

Hi All

I was wondering if it is possible to match keys partially while
searching in Cassandra.

I have a requirement where I'm storing a large number of records, the
key being something like "A|B|T" where A and B are mobile numbers and
T is the time-stamp (the time when A called B). Such format ensure the
uniqueness of the keys. Now if I want to search for all records where
A called B, I would like to do a partial match with "A|B". Is this
possible?

I've another small question - where can I find some complete examples
of creating a cluster and communicating with it (for
insertion/deletion of records) using Hector or Pelops? So far, I've
been doing this via the Thrift interface, but it's becoming illegible
now...

Thanks in advance...

Regards
Arijit

-- 
"And when the night is cloudy,
There is still a light that shines on me,
Shine on until tomorrow, let it be."

Re: partial matching of keys

Posted by Tyler Hobbs <ty...@riptano.com>.
Yes, you can basically do this two ways:

First, you can use an OrderPreservingPartitioner.  This stores your keys in
order, so you can grab the range of keys that begin with 'A|B'.  Because of
the drawbacks of OPP (unbalanced ring, hotspots), you almost certainly don't
want to do this.

Second, you take advantage of column name sorting.  For example, you can
have a row for all of the calls that A has made; each column name can be
something like 'B|T'. This allows you to quickly get all of the times when A
called
B in chronological order.  (You can have a second row or column family and
swap B
and T's position if you're more interested in time slices.)  This is very
much like the
Twitter clone, Twissandra:

https://github.com/ericflo/twissandra
http://twissandra.com/

As for examples, there are Hector examples here:

https://github.com/zznate/hector-examples

- Tyler

On Tue, Nov 30, 2010 at 12:11 AM, Arijit Mukherjee <ar...@gmail.com>wrote:

> Hi All
>
> I was wondering if it is possible to match keys partially while
> searching in Cassandra.
>
> I have a requirement where I'm storing a large number of records, the
> key being something like "A|B|T" where A and B are mobile numbers and
> T is the time-stamp (the time when A called B). Such format ensure the
> uniqueness of the keys. Now if I want to search for all records where
> A called B, I would like to do a partial match with "A|B". Is this
> possible?
>
> I've another small question - where can I find some complete examples
> of creating a cluster and communicating with it (for
> insertion/deletion of records) using Hector or Pelops? So far, I've
> been doing this via the Thrift interface, but it's becoming illegible
> now...
>
> Thanks in advance...
>
> Regards
> Arijit
>
> --
> "And when the night is cloudy,
> There is still a light that shines on me,
> Shine on until tomorrow, let it be."
>