birth_year is secondary indexed. When querying using 2nd indexes, Cassandra
(it's not CQL specific) requires that you use an '=' for at least one of
the indexed column in the where clause (in your example you only have one
such column so it should be an '='). This is a limitation of 2ndary indexes
(that will hopefully be lifted someday -
https://issues.apache.org/jira/browse/CASSANDRA-4476).

In other words, what you can do is:
 select * from users where birth_year = 1965
but your query is not supported (for 2nd indexes that is).

--
Sylvain


On Thu, Jan 31, 2013 at 7:22 AM, Dinusha Dilrukshi
<sdddilruk...@gmail.com>wrote:

> Hi All,
>
> I have created a column family as follows. (With secondary indexes.)
>
> create column family users with comparator=UTF8Type and
> key_validation_class = 'UTF8Type' and default_validation_class = 'UTF8Type'
>  and column_metadata=[{column_name: full_name, validation_class: UTF8Type},
>  {column_name: birth_year, validation_class: LongType, index_type: KEYS},
>  {column_name: state, validation_class:  UTF8Type, index_type: KEYS}];
>
> And I am using CQL driver-1.1.1 with Cassandra server-1.1.1. Once I try to
> execute the following query, it gives  an exception saying 'No indexed
> columns present in by-columns clause with "equals" operator'.
>
> CQL :
> select * from users where birth_year<1965
>
> Caused by: java.sql.SQLSyntaxErrorException: No indexed columns present in
> by-columns clause with "equals" operator
>     at
> org.apache.cassandra.cql.jdbc.CassandraPreparedStatement.doExecute(CassandraPreparedStatement.java:155)
>     at
> org.apache.cassandra.cql.jdbc.CassandraPreparedStatement.executeQuery(CassandraPreparedStatement.java:199)
>
> Appreciate any help to resolve this..
>
> Regards,
> Dinusha.
>

Reply via email to