本文介绍了Cassandra如何在表中添加聚类键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cassandra中有一个表

There is a table in cassandra

create table test_moments(id Text, title Text, sort int, PRIMARY KEY(id));

如何在 sort列中添加聚类键。不重新创建表

How add clustering key in column "sort". Not re-creating the table

推荐答案

主要问题是磁盘上的数据结构。集群键直接决定了如何对数据进行排序和序列化(然后搜索)到磁盘上,因此您无法提出要求。

The main problem is the on-disk data structure. Clustering key directly dictates how data is sorted and serialized to disk (and then searched), so what you're asking is not possible.

唯一的方法是将数据迁移到另一个表。根据您的数据,如果您有很多记录,在查询期间可能会遇到一些超时错误,因此请准备使用一些有用的技术(例如COPY命令或TOKEN函数)来调整迁移。

The only way is to "migrate" the data to another table. Depending on your data, if you have a lot of records you could encounter some timeout error during the queries, so be prepared to tweak your migration with some useful techniques such as the COPY command or the TOKEN function.

看看 SO问题。

这篇关于Cassandra如何在表中添加聚类键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 09:13