Database Reference
In-Depth Information
CREATE INDEX IF NOT EXISTS index_demo_address_val_idx ON
index_demo (address);
code=2200 [Invalid query] message="Cannot create index on
address values, an index on address keys already exists and
indexing a map on both keys and values at the same time is
not currently supported"
Something worth noticing; you can create an index on map keys or map values, but not on
both.
Also, the preceding example, with all the columns having indexes, is made up. The de-
cision to create an index is usually a requirement-driven one; so you may decide to create
an index later in the application development when you actually need it.
Cassandra allows users to create a custom indexing algorithm. You can create your own
indexing mechanism, wrap it into a jar, and drop it into Cassandra's lib folder. You will
have to mention the details of this new index when you are creating an index. The options
can be used to pass parameters to the class. The CUSTOM , USING , and OPTIONS
keywords are for the custom index. Here's an example:
CREATE CUSTOM INDEX index_name
ON
table_name (column_name)
USING 'fully.qualified.index.class.Name'
WITH OPTIONS = {
'param1': 'val1',
'param2': 'val2'
};
Dropping an index
Dropping an index is simple:
DROP INDEX [ IF EXISTS ] index_name;
You may have noticed that you can create indexes without providing a name. For those
cases, Cassandra assigned an automated name that has the following pattern:
{table_name}_{column_name}_idx;
Search WWH ::




Custom Search