我有以下数据模型: -
campaigns {
id int PRIMARY KEY,
scheduletime text,
SchduleStartdate text,
SchduleEndDate text,
enable boolean,
actionFlag boolean,
.... etc
}
在这里,我需要根据开始日期和结束数据获取数据,而不是ALLOW FILTERING
。我有更多的建议来重新设计模式以完全满足要求但我无法过滤基于id的数据,因为我需要b / w中的数据日期。
有人给我一个很好的建议来完全填写这个场景来执行以下查询: -
select * from campaings WHERE startdate='XXX' AND endDate='XXX' ;
//没有允许过滤的东西
CREATE TABLE campaigns (
SchduleStartdate text,
SchduleEndDate text,
id int,
scheduletime text,
enable boolean,
PRIMARY KEY ((SchduleStartdate, SchduleEndDate),id));
您可以对表格进行以下查询,
slect * from campaigns where SchduleStartdate = 'xxx' and SchduleEndDate = 'xx'; -- to get the answer to above question.
slect * from campaigns where SchduleStartdate = 'xxx' and SchduleEndDate = 'xx' and id = 1; -- if you want to filter the data again for specific ids
这里,SchduleStartdate和SchduleEndDate用作分区键,ID用作聚类键以确保条目是唯一的。
通过这种方式,您可以根据需要过滤开始,结束和后续ID。
这样做的一个缺点是,如果您只需要通过id进行过滤,因为您需要首先限制分区键。