卡桑德拉集合地图索引
cassandra collection map indexing
我有一个 Cassandra table,它的一列看起来像这样
"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;
请建议我一些方法来做到这一点..任何帮助将不胜感激
您不能在冻结的集合元素上创建索引
您必须在冻结集合上创建完整索引
Create an index on a full FROZEN collection. An FULL index can be created on a set, list, or map column of a table that doesn't have an existing index.
To index collection entries, you use the FULL keyword and collection name in nested parentheses
例如:
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]};
我有一个 Cassandra table,它的一列看起来像这样
"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;
请建议我一些方法来做到这一点..任何帮助将不胜感激
您不能在冻结的集合元素上创建索引
您必须在冻结集合上创建完整索引
Create an index on a full FROZEN collection. An FULL index can be created on a set, list, or map column of a table that doesn't have an existing index.
To index collection entries, you use the FULL keyword and collection name in nested parentheses
例如:
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]};