Cassandra Create Index
We can create an index in Cassandra, on the column specified by the user, by using the CREATE INDEX command. Indexes are created on the data if the data already exists for the selected column.
Syntax:
CREATE INDEX indexIdentifier ON tablename
Important Points:
- The primary key in Cassandra is already indexed and thus cannot be indexed.
- Collections in Cassandra cannot be indexed.
- A column cannot be filtered by Cassandra, without the indexing on that column, unless it is a primary key.
Example:
CREATE INDEX e_name ON employees (name); |
Explanation:
In the above example, we are creating an index ‘e_name’ on the column “name” of employees table.