Cassandra:更新聚类列的值

时间:2016-08-08 13:50:43

标签: cassandra-3.0

我创建了这个表:

CREATE TABLE postsbyuser(
  userid bigint,
  posttime timestamp,
  postid uuid,
  postcontent text,
  year bigint,
  PRIMARY KEY ((userid,year), posttime)
) WITH CLUSTERING ORDER BY (posttime DESC); 

我的查询是获取desc posttime命令的一年内所有用户帖子。 订购是一切都好,但问题是如果用户编辑postcontent,将改变posttime:

update postsbyuser set postcontent='edited content' and posttime=edit_time where userid=id and year=year

我收到错误:[Invalid query] message="PRIMARY KEY part time found in SET part"

您知道如何订购更改时间的帖子吗?

1 个答案:

答案 0 :(得分:-1)

您应该在查询中指定群集列。

update postsbyuser set postcontent='edited content' and posttime=edit_time where userid=id and year=year and posttime=previous_post_time