Apache Cassandra 1.2 Documentation

Indexing a column

The Cassandra 1.2 documentation is transitioning to a new format!
Please use the new Cassandra 1.2 documentation instead.
Back to Table of Contents
All Documents List     

You can use cqlsh can to create a secondary index (indexes on column values). This example creates an index on the state and birth_year columns in the users table.

cqlsh:demodb> CREATE INDEX state_key ON users (state);
cqlsh:demodb> CREATE INDEX birth_year_key ON users (birth_year);

Because you created the secondary index on the two columns, the column values can be queried directly:

cqlsh:demodb> SELECT * FROM users
                WHERE gender = 'f' AND
                state = 'TX' AND
                birth_year > 1968
                ALLOW FILTERING;