Cassandra - CQL OR Operator

巧了我就是萌 提交于 2020-02-05 08:27:08

问题


I am trying to learn cassandra. I am using windows community edition (2.0).

My table schema is:

CREATE TABLE test.TestTable2 (
PK1 int,
PK2 int,
CK3 int,
CK4 int,
Dump text,
PRIMARY KEY ((PK1,PK2,CK3),CK4)
);

I want to query the dump value for (PK1=1 and Pk2 =2 and Ck3 =5 and CK4 in (4,5)) or (PK1=2 and Pk2 =2 and Ck3 =5 and CK4 in (4,5)). I am unable to use or condition , can someone suggest how can I do that in CQL


回答1:


There is no support for OR operator: what you'd like to do is hit 2 partitions so it must be done by two different queries.

Query 1: (PK1=1 and Pk2 =2 and Ck3 =5 and CK4 in (4,5)) 
Query 2: (PK1=2 and Pk2 =2 and Ck3 =5 and CK4 in (4,5))

You can implement the "short circuit" by yourself: perform at first the query you'd expect to have bigger possibilities to retrieve the result -- If you got the result stop your process, if not perform second query.



来源:https://stackoverflow.com/questions/26309198/cassandra-cql-or-operator

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!