title: Creating a custom index on a collection using CQL 3.0
body: <p>I have been looking at the CQL 3.0 <a href="http://www.datastax.com/documentation/cql/3.0/webhelp/cql/ddl/ddl_anatomy_table_c.html#concept_ds_qqw_1dy_zj" rel="nofollow">data modelling documentation</a> which describes a column family of songs with tags, created like this:</p>
  
  <pre><code>CREATE TABLE songs (
      id uuid PRIMARY KEY,
      title text,
      tags set&lt;text&gt;
  );
  </code></pre>
  
  <p>I would like to get a list of all songs which have a specific tag, so I need to add an appropriate index.</p>
  
  <p>I can create an index on the <code>title</code> column easily enough, but if I try to index the <code>tags</code> column which is a collection, like this:</p>
  
  <pre><code>CREATE INDEX ON songs ( tags );
  </code></pre>
  
  <p>I get the following error from the DataStax Java driver 1.0.4:</p>
  
  <pre><code>Exception in thread "main" com.datastax.driver.core.exceptions.InvalidQueryException: Indexes on collections are no yet supported
  at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:35)
  at com.datastax.driver.core.ResultSetFuture.extractCauseFromExecutionException(ResultSetFuture.java:269)
  </code></pre>
  
  <p>It looks like this may be fixed in a later version of Cassandra (2.1) according to JIRA issue <a href="https://issues.apache.org/jira/browse/CASSANDRA-4511" rel="nofollow">CASSANDRA-4511</a>. I am currently using Apache Cassandra 1.2.11 however, and do not want to upgrade yet. According to issue <a href="https://issues.apache.org/jira/browse/CASSANDRA-5615" rel="nofollow">CASSANDRA-5615</a> though, in Cassandra 1.2.6 there <em>is</em> support for <em>custom indexes</em> on collections.</p>
  
  <p>The problem is, the only <a href="http://www.datastax.com/documentation/cql/3.1/webhelp/cql/cql_reference/create_index_r.html" rel="nofollow">documentation</a> available states:</p>
  
  <blockquote>
    <p>Cassandra supports creating a custom index, which is for internal use and beyond the scope of this document.</p>
  </blockquote>
  
  <p>But, it <em>does</em> suggest the following syntax:</p>
  
  <pre><code>CREATE CUSTOM INDEX ON songs ( tags ) USING 'class_name';
  </code></pre>
  
  <p>What is the <code>class_name</code> that is specified in this CQL statement?</p>
  
  <p>Is there a better way of indexing the tags so that I can query the <em>songs</em> table for a list of songs that have a specific tag?</p>