Using cqlsh to create an index on column values.
You can use cqlsh to create an index on
column values. In Apache Cassandra™ 2.1 and later, you can index
collection columns. Indexing can impact performance greatly. Before
creating an index, be aware of when and when not to create an
index.
Procedure
-
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);
-
Query the columns that are now indexed.
cqlsh:demodb> SELECT * FROM users
WHERE gender = 'f' AND
state = 'TX' AND
birth_year > 1968
ALLOW FILTERING;