CQL:错误请求:缺少列的CLUSTERING ORDER

时间:2014-04-20 17:15:10

标签: cassandra cql3

此CQL查询有什么问题

cqlsh> create table citybizz.notifications(
   ...      userId varchar,
   ...      notifId UUID,
   ...      notification varchar,
   ...      time bigint,read boolean,
   ...      primary key (userId, notifId,time)
   ... ) with clustering order by (time desc);

抛出Bad Request: Missing CLUSTERING ORDER for column notifid。我正在使用cassandra 1.2.2

1 个答案:

答案 0 :(得分:8)

您还需要指定notifId的顺序:

create table citybizz.notifications(
    userId varchar,
    notifId UUID,
    notification varchar,
    time bigint,read boolean,
    primary key (userId, notifId,time)
) with clustering order by (notifId asc, time desc);

Cassandra并不假设其他群集密钥的默认排序(asc),因此您需要指定它。