Question

I would like to create and use an index on "age" key of a standard column family.

I did the following using pycassa:

In [10]: sys.create_index('test01', 'word_map', 'age', 'IntegerType', index_type=0, index_name='index_age')
In [11]: age_expr = create_index_expression('age', 6, GT)
In [12]: clause = create_index_clause([age_expr], count=20)
In [13]: cf.get_indexed_slices(clause)

error: 'No indexed columns present in index clause with operator EQ'

According to this nice page, I need to set the value type. However:

In [16]:  cf_words.column_validators
Out[16]: {'black_white': 'BooleanType', 'url': 'UTF8Type', 'age': 'IntegerType', 'site': 'UTF8Type', 'len': 'IntegerType', 'content': 'UTF8Type', 'colourful': 'BooleanType', 'printer_friendly': 'BooleanType'}

so age has a data type set.

Any ideas?

Était-ce utile?

La solution

Instead of the string 'GT', use pycassa.index.GT. It's an enum that Thrift implements with integers.

You can find all of the documentation and an example usage here: http://pycassa.github.com/pycassa/api/pycassa/index.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top