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

man*_*ish 6 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);
Run Code Online (Sandbox Code Playgroud)

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

Ric*_*ard 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);
Run Code Online (Sandbox Code Playgroud)

Cassandra不会假设其他群集键的默认排序(asc),因此您需要指定它.