Cassandra は、最初のクエリ(特定の範囲内の値を持つ文字列のすべてのペア) をサポートしていません。現在、Cassandra では、少なくとも 1 つEQ
のWHERE
句を含む範囲クエリのみが許可されているためです。ただし、2番目と3番目のクエリは実行可能です:)
例
次の例を検討してください。
cqlsh:so> desc table string_mappings;
CREATE TABLE string_mappings (
s1 ascii,
s2 ascii,
value float,
PRIMARY KEY (s1, s2, value)
)
そして、次のタプルがあります。
cqlsh:so> select * from string_mappings;
s1 | s2 | value
-------+-------+-------
hello | hello | 1
hello | world | 0.2
stack | hello | 0
stack | stack | 1
stack | world | 0
world | world | 1
EQ
Cassandra は現在、 on theWHERE
句のない範囲クエリをサポートしていないため、最初のクエリは機能しません。
cqlsh:so> select * from string_mappings where value>0.5;
Bad Request: PRIMARY KEY part value cannot be restricted (preceding part s2 is either not restricted or by a non-EQ relation)
ただし、次の範囲クエリ (2 番目のクエリ) は、次のものがあるため問題ありませんEQ
。
cqlsh:so> select * from string_mappings where value > 0.5 and s2='hello' allow filtering;
s1 | s2 | value
-------+-------+-------
hello | hello | 1
キーワードを入れることを忘れないでALLOW FILTERING
ください。そうしないと、次のエラーが発生します。
cqlsh:so> select * from string_mappings where value > 0.5 and s2='hello';
Bad Request: Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING
最後に、3 番目のクエリも問題ではありません :)
cqlsh:so> select * from string_mappings where S1='hello' and S2='world';
s1 | s2 | value
-------+-------+-------
hello | world | 0.2