【问题标题】:Clustering column "status" cannot be restricted (preceding column "datetime" is restricted by a non-EQ relation不能限制聚类列“状态”(前面的列“日期时间”受非 EQ 关系限制
【发布时间】:2018-08-23 10:15:15
【问题描述】:

我的日期时间列仅用于排序目的,其余的聚类键用于过滤。但是如果不给日期时间赋予等效值,我就无法按其他列进行过滤。如果我使用 Apache solr,我可以解决我的问题吗?

我的桌子:

create table search_by_company_id_status
(
agency_id   text,
datetime    timestamp,
createid    text,
status  text,
primary key ((agency_id),datetime,status,createid)) with clustering order by (datetime desc);

我正在尝试的查询:

select * from search_by_agency_id_status  where agency_id='125' and datetime>'2018-02-02 12:00:00.000' and recordstatus='7' and createid='id234';

【问题讨论】:

    标签: solr cassandra datastax


    【解决方案1】:

    根据您提供的查询,您将使用“等于”谓词对其余聚类列(即“status”和“createdid”)进行过滤。

    您可以按如下方式重新设计表格,以保证日期时间的排序顺序(因为每个先前的值都被过滤为单个值)。

    create table search_by_company_id_status
    (
    agency_id   text,
    datetime    timestamp,
    createid    text,
    status  text,
    primary key ((agency_id),status,createid,datetime)) with clustering order by (datetime desc);
    

    这个查询应该可以正常工作

    select * from search_by_agency_id_status  where agency_id='125' and status='7' and createid='id234' and datetime>'2018-02-02 12:00:00.000';
    

    【讨论】:

    • 我没有遵循这一点,因为我并不总是按状态和 createid 过滤,这两列只是可选的猜测我将不得不再创建 2 个表来满足过滤。感谢您的回答。
    猜你喜欢
    • 2017-10-01
    • 2016-03-29
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多