Apache Cassandra™ 1.2

Indexing a column

The CLI can be used to create indexes on column values. You can add the index when you create a table or add it later using the UPDATE COLUMN FAMILY command.

Procedure

  1. Add an index to the birth_year column of the users column family.
    [default@demo] UPDATE COLUMN FAMILY users WITH comparator = UTF8Type
      AND column_metadata =
        [{column_name: birth_year,
          validation_class: LongType,
          index_type: KEYS
         }
        ];
  2. Query Cassandra for users born in a given year.
    [default@demo] GET users WHERE birth_year = 1969;
Show/hide