【问题标题】:Is it possible to pass any other columns after the where clause in select statement Cassandra是否可以在 select 语句 Cassandra 中的 where 子句之后传递任何其他列
【发布时间】:2012-04-24 19:24:21
【问题描述】:

我一直在尝试使用以下命令从 Cassandra 数据库中检索数据:

 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 中是否不可能在非主键的帮助下过滤数据?

【问题讨论】:

    标签: select primary-key cassandra where cql


    【解决方案1】:

    您不能直接在原版列族上执行此操作。 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.

    【讨论】:

    • 谢谢保罗。这真的很有帮助。非常感谢。
    • 确保将答案标记为已解决,以便其他路过的人知道这是正确的。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-14
    • 1970-01-01
    • 2017-01-16
    • 2010-12-12
    • 2011-09-19
    相关资源
    最近更新 更多