Skip to content

Adding Secondary Indexes #21

alanpeabody opened this Issue Apr 9, 2012 · 2 comments

2 participants


I would like to be able to add secondary index to a column family via clj-hector.

I don't believe there is a way to do this currently.

@rplevy-draker and myself would be willing to write the code to add this functionality if you have an idea of how you might like to see it implemented.


I think the first step would be to allow creating a new column family with an index. Currently we don't have a way to update a column family/keyspace after it is created. Hopefully adding the functionality to the cf creation call will make it easy to add a fn for updating column families that takes advantage of that. At first glance I would imagine this would be an additional possible option passed to the 'make-column-family' function in ddl.clj

The implementation would actually be generalized to allow setting the column_metadata for a column family. That will allow you to create an index as well as just set validators for certain columns. Column metadata is just a list of individual column definitions so something like:

(make-column-family "my_keyspace" 
  {:name "cf1"
   :type :standard
     [{:name "c1" :index-name "c1_idx" :index-type :keys :validator :utf8}
      {:name "c2" :validator :integer}])

Above would be an example of both an indexed column as well as just column with a validator. You can see a good example of what the hector code looks like here too:

Once that is in place, an update column family function can be added that can retrieve the existing ColumnFamilyDefinition from hector, update the fields passed in by the user, and call the hector method for updating a column family.


Fixed with pull request 22.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.