我有一个Cassandra表,其中一列看起来像这样
"ArticlesViewed" frozen<map<int, frozen<list<int>>>>
and it contains data like
ArticlesViewed
-----------------------------------------------
{400: [9, 19, 11, 12], 545: [183, 44, 25, 16, 97]}
{812: [2, 44, 41, 22], 376: [123, 14, 15, 16, 47]}
{134: [9, 10, 11, 92], 111: [533, 14, 15, 16, 27]}
我想在此列上创建索引,以(不允许过滤)此列但不允许我这样做
cqlsh>CREATE INDEX ON user_profile("ArticlesViewed");
[Invalid query] message="Cannot create values() index on frozen column ArticlesViewed.
Frozen collections only support full() indexes"
Also,i want to query on the <value> {400: [9, 19, 11, 12],of the column like
select "ArticlesViewed" from user_profile where "ArticlesViewed" =19;
请建议我一些方法来做到这一点..任何帮助将不胜感激
答案 0 :(得分:0)
您无法在冻结的集合元素上创建索引
您必须在冻结集合上创建完整索引
在完整的FROZEN集合上创建索引。可以在没有现有索引的表的set,list或map列上创建FULL索引。
要索引集合条目,请在嵌套括号中使用FULL关键字和集合名称
例如:
CREATE INDEX on user_profile(full(articlesviewed));
使用完整索引,如果要查询articlesviewed,则必须指定完整的集合值。因为它被冻结了。
如果您有数据:
userid | articlesviewed
--------+----------------------------------
1 | {1: [1, 2, 3], 10: [10, 20, 30]}
您的查询应包含articlesviewed的全部值
SELECT * FROM user_profile WHERE articlesviewed = {1: [1, 2, 3], 10: [10, 20, 30]};