Cannot getWhere using other Operator, except Equality
anhphuong opened this issue · 8 comments
Hi, I have an problem when I try to get data by Operator Greater & Less than.
First, I use this code:
$aged24 = $cassandra->cf ( 'user' )->getWhere ( array (
array (
'age',
Cassandra::OP_EQ,
24
)
) );
echo 'Users 24:
' . print_r ( $aged24->getAll(), true ) . '
';
The result OK, it showed:
Array
(
[jane.doe] => Array
(
[age] => 24
[email] => jane@doe.com
[name] => Jane Doe
)
)
But, when I want get Greater, I changed code to:
$aged20plus = $cassandra->cf ( 'user' )->getWhere ( array (
array (
'age',
Cassandra::OP_GT,
20
)
) );
echo 'Users 20+:
' . print_r ( $aged20plus->getAll(), true ) . '
';
The result have Exception: "Failed calling "get_indexed_slices" the maximum of 5 times"
Please help me solve this problem. Thanks so much ^_^
Are you using order-preserving partitioner?
Thanks so much for your care, kallaspriit :D
I don't understand mush about your question. I only tried run "example.php", and then I add new code for purpose Select list of data where age greater than 20 (at example.php, it only have code to Select where age equal 24 year)
so, are you sure this problem is about Cassandra Server config ?
Most likely, the example.php includes a comparison OP too that is commented out because it does not work with default config.
Hi kallaspriit,
Thanks a lot for your help :D
I try open file cassandra.yaml follow your guide, then change the line:
partitioner: org.apache.cassandra.dht.Murmur3Partitioner
to
partitioner: org.apache.cassandra.dht.OrderPreservingPartitioner
Then, I restart Cassandra.
I try run my code (php) again, it still had above problem :(
So, what's wrong I missed ?
Hi kallaspriit,
I try uncomment this line:
$usersAZ = $cassandra->cf ( 'user' )->getKeyRange ( 'a', 'z' );
print_r ( $usersAZ->getAll (), true );
The result show OK like that:
Array
(
[jane.doe] => Array
(
[age] => 24
[email] => jane@doe.com
[name] => Jane Doe
)
[john] => Array
(
[age] => 34
[email] => john@smith.com
[name] => John Smith
)
)
But, my code:
$aged20plus = $cassandra->cf ( 'user' )->getWhere ( array (
array (
'age',
Cassandra::OP_GT,
20
)
) );
print_r ( $aged20plus->getAll(), true );
Still show Exception: "Failed calling "get_indexed_slices" the maximum of 5 times" :(