incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Malone <m...@simplegeo.com>
Subject Re: How to write WHERE .. LIKE query ?
Date Tue, 11 May 2010 16:01:49 GMT
On Tue, May 11, 2010 at 8:54 AM, Schubert Zhang <zsongbo@gmail.com> wrote:

> In the future, maybe cassandra can provide some "Filter" or "Coprocessor"
> interfaces. Just like what of Bigtable do.
> But now, cassandra is too young, there are many things to do for a clear
> core.


There's been talk of adding coprocessors. It will probably happen one day.
Unfortunately, that day is probably a ways off.

Mike


>
>
> On Tue, May 11, 2010 at 11:35 PM, Mike Malone <mike@simplegeo.com> wrote:
>
>> On Mon, May 10, 2010 at 11:36 PM, vd <vineetdaniel@gmail.com> wrote:
>>
>>> Hi Mike
>>>
>>> AFAIK cassandra queries only on keys and not on column names, please
>>> verify.
>>>
>>
>> Incorrect. You can slice a row or rows (identified by a key) on a column
>> name range (e.g., "a" through "m") or ask for specific columns in a row or
>> rows (e.g., please give me the "first_name," "last_name" and
>> "hashed_password" fields from my Users column family where the key equals
>> "mmalone").
>>
>> See the get_range_slices() method in the thrift service.
>>
>> Mike
>>
>>
>>>
>>>
>>>
>>> On Tue, May 11, 2010 at 11:06 AM, Mike Malone <mike@simplegeo.com>
>>> wrote:
>>> >
>>> >
>>> > On Mon, May 10, 2010 at 9:00 PM, Shuge Lee <shuge.lee@gmail.com>
>>> wrote:
>>> >>
>>> >> Hi all:
>>> >> How to write WHERE ... LIKE query ?
>>> >> For examples(described in Python):
>>> >> Schema:
>>> >> # columnfamily name
>>> >> resources = [
>>> >>    # key
>>> >>     'foo': {
>>> >>         # columns and value
>>> >>         'url': 'foo.com',
>>> >>         'pushlier': 'foo',
>>> >>     },
>>> >>     'oof': {
>>> >>         'url': 'oof.com',
>>> >>         'pushlier': 'off',
>>> >>     },
>>> >>    #  ... ,
>>> >> }
>>> >> # this is very easy,
>>> >> SELECT * FROM KEY = 'foo'
>>> >> but following are really hard:
>>> >> SELECT * FROM resources WHERE key LIKE 'o%' # get all records which
>>> key
>>> >> name contains character 'o'?
>>> >
>>> > get_range_slices(<keyspace>, ColumnParent(column_family),
>>> > SlicePredicate(slice_range=SliceRange('',''), KeyRange('o', 'o~'),
>>> > ConsistencyLevel.ONE);
>>> >
>>> >>
>>> >> SELECT * FROM resources WHERE url == 'oof.com'
>>> >
>>> > This is a projection. Cassandra doesn't support this sort of query out
>>> of
>>> > the box. You'll have to structure your data so that data you want to
>>> query
>>> > by is in the key or column name. Or you'll have to manually build
>>> secondary
>>> > indexes.
>>> >
>>> > Mike
>>> >
>>>
>>
>>
>

Mime
View raw message