You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Rauan Maemirov <ra...@maemirov.com> on 2011/02/18 13:46:57 UTC

Queries on secondary indexes

With this schema:

create column family Userstream with comparator=UTF8Type and rows_cached =
10000 and keys_cached = 100000
and column_metadata=[{column_name:account_id, validation_class:IntegerType,
index_type: 0, index_name:UserstreamAccountidIdx},
{column_name:from_id, validation_class:IntegerType, index_type: 0,
index_name:UserstreamFromidIdx},
{column_name:type, validation_class:IntegerType, index_type: 0,
index_name:UserstreamTypeIdx}];

I'm having this:

[default@Keyspace1] get Userstream where from_id=5 and type<4;
-------------------
RowKey: 23:feed:12980301937245
=> (column=account_id, value=23, timestamp=1298031252270173)
=> (column=activities,
value=5b2232313864333936302d336235362d313165302d393838302d666235613434333135343865225d,
timestamp=1298031252270173)
=> (column=from_id, value=5, timestamp=1298031252270173)
=> (column=type, value=5, timestamp=1298031252270173)
-------------------
RowKey: 5:feed:12980301937196
=> (column=account_id, value=5, timestamp=1298031252270173)
=> (column=activities,
value=5b2232313863376339302d336235362d313165302d623536342d666235303739333835303234225d,
timestamp=1298031252270173)
=> (column=from_id, value=5, timestamp=1298031252270173)
=> (column=type, value=5, timestamp=1298031252270173)
-------------------
RowKey: 9:feed:12980301937207
=> (column=account_id, value=9, timestamp=1298031252270173)
=> (column=activities,
value=5b2232313863613637302d336235362d313165302d393333622d373530393638613764326561225d,
timestamp=1298031252270173)
=> (column=from_id, value=5, timestamp=1298031252270173)
=> (column=type, value=0, timestamp=1298031252270173)

3 Rows Returned.


and

[default@Keyspace1] get Userstream where from_id=5 and type=5;

0 Row Returned.



What's wrong with it?

Re: Queries on secondary indexes

Posted by Jonathan Ellis <jb...@gmail.com>.
If your question is "why are some of the values in hex," it's because
you didn't specify a validation_class on the other columns.

On Fri, Feb 18, 2011 at 6:46 AM, Rauan Maemirov <ra...@maemirov.com> wrote:
> With this schema:
> create column family Userstream with comparator=UTF8Type and rows_cached =
> 10000 and keys_cached = 100000
> and column_metadata=[{column_name:account_id, validation_class:IntegerType,
> index_type: 0, index_name:UserstreamAccountidIdx},
> {column_name:from_id, validation_class:IntegerType, index_type: 0,
> index_name:UserstreamFromidIdx},
> {column_name:type, validation_class:IntegerType, index_type: 0,
> index_name:UserstreamTypeIdx}];
> I'm having this:
> [default@Keyspace1] get Userstream where from_id=5 and type<4;
> -------------------
> RowKey: 23:feed:12980301937245
> => (column=account_id, value=23, timestamp=1298031252270173)
> => (column=activities,
> value=5b2232313864333936302d336235362d313165302d393838302d666235613434333135343865225d,
> timestamp=1298031252270173)
> => (column=from_id, value=5, timestamp=1298031252270173)
> => (column=type, value=5, timestamp=1298031252270173)
> -------------------
> RowKey: 5:feed:12980301937196
> => (column=account_id, value=5, timestamp=1298031252270173)
> => (column=activities,
> value=5b2232313863376339302d336235362d313165302d623536342d666235303739333835303234225d,
> timestamp=1298031252270173)
> => (column=from_id, value=5, timestamp=1298031252270173)
> => (column=type, value=5, timestamp=1298031252270173)
> -------------------
> RowKey: 9:feed:12980301937207
> => (column=account_id, value=9, timestamp=1298031252270173)
> => (column=activities,
> value=5b2232313863613637302d336235362d313165302d393333622d373530393638613764326561225d,
> timestamp=1298031252270173)
> => (column=from_id, value=5, timestamp=1298031252270173)
> => (column=type, value=0, timestamp=1298031252270173)
> 3 Rows Returned.
>
> and
> [default@Keyspace1] get Userstream where from_id=5 and type=5;
> 0 Row Returned.
>
>
> What's wrong with it?



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of DataStax, the source for professional Cassandra support
http://www.datastax.com

Re: Queries on secondary indexes

Posted by Rauan Maemirov <ra...@maemirov.com>.
Hm, phpcassa works great, I guess that is the problem of cli. Now it doesn't
return any rows at all.

2011/2/18 Rauan Maemirov <ra...@maemirov.com>

> With this schema:
>
> create column family Userstream with comparator=UTF8Type and rows_cached =
> 10000 and keys_cached = 100000
> and column_metadata=[{column_name:account_id, validation_class:IntegerType,
> index_type: 0, index_name:UserstreamAccountidIdx},
>  {column_name:from_id, validation_class:IntegerType, index_type: 0,
> index_name:UserstreamFromidIdx},
> {column_name:type, validation_class:IntegerType, index_type: 0,
> index_name:UserstreamTypeIdx}];
>
> I'm having this:
>
> [default@Keyspace1] get Userstream where from_id=5 and type<4;
> -------------------
> RowKey: 23:feed:12980301937245
> => (column=account_id, value=23, timestamp=1298031252270173)
> => (column=activities,
> value=5b2232313864333936302d336235362d313165302d393838302d666235613434333135343865225d,
> timestamp=1298031252270173)
> => (column=from_id, value=5, timestamp=1298031252270173)
> => (column=type, value=5, timestamp=1298031252270173)
> -------------------
> RowKey: 5:feed:12980301937196
> => (column=account_id, value=5, timestamp=1298031252270173)
> => (column=activities,
> value=5b2232313863376339302d336235362d313165302d623536342d666235303739333835303234225d,
> timestamp=1298031252270173)
> => (column=from_id, value=5, timestamp=1298031252270173)
> => (column=type, value=5, timestamp=1298031252270173)
> -------------------
> RowKey: 9:feed:12980301937207
> => (column=account_id, value=9, timestamp=1298031252270173)
> => (column=activities,
> value=5b2232313863613637302d336235362d313165302d393333622d373530393638613764326561225d,
> timestamp=1298031252270173)
> => (column=from_id, value=5, timestamp=1298031252270173)
> => (column=type, value=0, timestamp=1298031252270173)
>
> 3 Rows Returned.
>
>
> and
>
> [default@Keyspace1] get Userstream where from_id=5 and type=5;
>
> 0 Row Returned.
>
>
>
> What's wrong with it?
>

Re: Queries on secondary indexes

Posted by Norman Maurer <no...@apache.org>.
No sure whats your problem..

Use two EQ operations works without a problem here (even via the cli).

Bye,
Norman

2011/2/18 Rauan Maemirov <ra...@maemirov.com>:
> With this schema:
> create column family Userstream with comparator=UTF8Type and rows_cached =
> 10000 and keys_cached = 100000
> and column_metadata=[{column_name:account_id, validation_class:IntegerType,
> index_type: 0, index_name:UserstreamAccountidIdx},
> {column_name:from_id, validation_class:IntegerType, index_type: 0,
> index_name:UserstreamFromidIdx},
> {column_name:type, validation_class:IntegerType, index_type: 0,
> index_name:UserstreamTypeIdx}];
> I'm having this:
> [default@Keyspace1] get Userstream where from_id=5 and type<4;
> -------------------
> RowKey: 23:feed:12980301937245
> => (column=account_id, value=23, timestamp=1298031252270173)
> => (column=activities,
> value=5b2232313864333936302d336235362d313165302d393838302d666235613434333135343865225d,
> timestamp=1298031252270173)
> => (column=from_id, value=5, timestamp=1298031252270173)
> => (column=type, value=5, timestamp=1298031252270173)
> -------------------
> RowKey: 5:feed:12980301937196
> => (column=account_id, value=5, timestamp=1298031252270173)
> => (column=activities,
> value=5b2232313863376339302d336235362d313165302d623536342d666235303739333835303234225d,
> timestamp=1298031252270173)
> => (column=from_id, value=5, timestamp=1298031252270173)
> => (column=type, value=5, timestamp=1298031252270173)
> -------------------
> RowKey: 9:feed:12980301937207
> => (column=account_id, value=9, timestamp=1298031252270173)
> => (column=activities,
> value=5b2232313863613637302d336235362d313165302d393333622d373530393638613764326561225d,
> timestamp=1298031252270173)
> => (column=from_id, value=5, timestamp=1298031252270173)
> => (column=type, value=0, timestamp=1298031252270173)
> 3 Rows Returned.
>
> and
> [default@Keyspace1] get Userstream where from_id=5 and type=5;
> 0 Row Returned.
>
>
> What's wrong with it?