2012-04-12 70 views
5

我一直在尝试使用此命令检索卡桑德拉数据库中的数据后通过任何其他列:是否有可能在select语句的where子句卡桑德拉

select A_NO from Activity where CALL_TYPE IN ('MOC');//here CALL_TYPE is not the row id 

但其显示:

Expected key 'KEY' to be present in where clause for 'Activity' 

cassandra是否可以在非主键的帮助下过滤数据?

回答

6

你不能直接在香草柱系列上做到这一点。 Cassandra默认只让你查询关键字或关键字范围。您可以通过在列创建一个辅助指标完成这个

你会运行一个CQL这样的查询创建两个指标:

cqlsh> CREATE INDEX state_key ON users (state); 
cqlsh> CREATE INDEX birth_year_key ON users (birth_year); 

然后询问这样的:

cqlsh> SELECT * FROM users 
... WHERE gender='f' AND 
... state='TX' AND 
... birth_year='1968'; 

Here is more on Secondary indexes.

Here is the documentation on using CQL for this.

+1

谢谢保罗。这真的很有帮助。非常感谢。 – abhi 2012-04-13 11:39:31

+1

确保您将答案标记为已解决,以便其他人知道这是正确的。谢谢! – 2012-04-13 14:44:11