Cassandra:创建复合类型列
我是cassandra的新手,我正在尝试创建一个模式,使我可以将行作为Cassandra:创建复合类型列,cassandra,composite,cql,Cassandra,Composite,Cql,我是cassandra的新手,我正在尝试创建一个模式,使我可以将行作为 users: { name: <value>, ... phone_numbers:1: <value>, phone_numbers:2: <value>, ... phone_numbers: <value> } 上述方法失败了。 谢谢你的帮助 cassandra中的cheers复合类型可以用作比较器[列名类型]或键验证类
users: {
name: <value>,
...
phone_numbers:1: <value>,
phone_numbers:2: <value>,
...
phone_numbers: <value>
}
上述方法失败了。
谢谢你的帮助
cassandra中的cheers复合类型可以用作
比较器
[列名类型]或键验证类
[行键类型],但不能用作默认值验证类
[列值类型]
create column family users with
comparator='CompositeType(UTF8Type, IntegerType)'
and key_validation_class='UTF8Type'
应该对你有用。我在CQL3中分享了关于cassandra中复合类型的详细信息,您可以将其声明为:(为了简单起见,使用ascii类型) 创建表用户(用户ascii、电话ID ascii、电话号码ascii、, 主键(用户、电话号码)具有紧凑的存储空间 填写为 插入用户(用户、phoneid、phonenumber值('john smith'、'home'、'555-121345')) 插入用户(用户、phoneid、phonenumber值('john smith'、'office'、'555-121346')) 并将其检索为 从用户中选择*,其中用户='john smith' 用户、电话ID、电话号码 “约翰·史密斯”,“家”,“555-121345” “约翰·史密斯”,“办公室”,“555-121346”
希望它能有所帮助那么,设计我的模式的最佳方法是使用两个CFs吗?一个是用于comparator=AsciitType的用户,另一个是用于comparator=CompositeType(AsciitType,IntegerType)的用户\电话\号码?我认为你的OP是regd创建复合类型:P如果你需要架构方面的帮助,请尝试描述你的用例和读写模式。这很有帮助,因此我仍然只能按键的一部分进行搜索,但复合键允许我存储数组。
create column family users with
comparator='CompositeType(UTF8Type, IntegerType)'
and key_validation_class='UTF8Type'