如何在cassandra数据库2.2.1中基于列表中的值进行搜索

时间:2016-02-01 08:29:12

标签: list search dictionary cassandra

create table tbl_master_values (
dbid int primary key,
user_dbid int, reg_dbid int,
module_dbid int,
fields_value map<text,list<text>>,
created_date timestamp,
modified_date timestamp);

CREATE INDEX idx_fields_value ON tbl_master_values (keys(fields_value));

Fields_values列包含此值:

{'287': ['28'], '288': [''], '289': [''], '291': ['33'], '295': [''],'309': ['214', '215']} 

现在我想根据fields_value列的map里面的列表中的值进行搜索。我也试过这个:

cqlsh:sampledb> select * from tbl_master_values where fields_value['309'] contains '215';

显示如下错误:

InvalidRequest: code=2200 [Invalid query] message="No secondary indexes on
the restricted columns support the provided operators: 'fields_value = <value>'"

cqlsh:crmdb> select * from tbl_master_values where fields_value['309']=['215'];

显示如下错误:

InvalidRequest: code=2200 [Invalid query] message="No secondary indexes on 
the restricted columns support the provided operators: 'fields_value = <value>'"

1 个答案:

答案 0 :(得分:0)

您需要的是条目上的索引,而不仅仅是地图键

试试这个

CREATE INDEX idx_fields_value ON tbl_master_values (ENTRIES(fields_value));

但更一般地说,这种二级索引不能很好地扩展到簇大小,因为每个请求都会遇到很多节点(节点/ RF的数量准确)