Cassandra CQL select '!=' 运算符

Cassandra CQL select '!=' operator

我知道 != 在 CQL select 语句中不受支持。而且,我也知道 != 查询效率不高。但是为什么我准备接受过滤还是不允许呢?

例如,我想要这样的东西:Select * from foo where PK='something' and CK1='something' and CK2!='something' allow filtering

我的理由是,在 PKCK1 之后基数会足够低,我不在乎 Cassandra 是否必须读取所有剩余的行。

问题:除了做应用端过滤,有没有办法只使用 CQL 来做?

不行,没有别的办法。得从应用层过滤。

Cassandra supports these conditional operators in the WHERE clause: CONTAINS, CONTAINS KEY, IN, =, >, >=, <, or <=, but not all in certain situations.

来源:https://docs.datastax.com/en/cql/3.1/cql/cql_reference/select_r.html