conn->prepare($cql); $response = $this->con_cassandra php语法">
赞
踩
1、使用 prepare 函数,设置 page_size=5 成功查询5条记录 ,
$cql ="select * from revall_books where solr_query = 'companyid:2 && status:0 '";
$preparedData = $this->conn->prepare($cql);
$response = $this->conn->executeSync(
$preparedData['id'], [], Cassandra\Request\Request::CONSISTENCY_QUORUM, [
'page_size' => 5,
'names_for_values' => true,
'skip_metadata' => true,
]
);
$response->setMetadata($preparedData['result_metadata']);
$rows = $response->fetchAll();
2、将sql 改为 $cql =”select * from revall_books where solr_query = ‘companyid:2 && status:0 ‘”;
报错误:
Invalid: Unsupported consistency level: QUORUM. Supported consistency levels for search are: ONE, LOCAL_ONE
3 、php-cassandra 中 Cassandra\Request\Request::CONSISTENCY_QUORUM 类型不支持solr 查询,将此参数设置为null,然后使用下面的分页方式。
4、cassandra 分页效果可以使用下面两种方式
$cql ="select * from revall_books where solr_query = 'companyid:2 && status:0 ' limit 10 order by date"
select * from revall_books where solr_query = '{"q" : "companyid:2 && status:0", "start" : 11}' limit 10 ;
solor_query内容为标准json字符串,
q: 要查询的条件,
start:结果偏移量,从0开始 ,配合limit 使用,如:每页查询5条记录,查询第二页数据时 limit 为5 ,start 为5
附:
Php-Cassandra 分页参考 : https://github.com/duoshuo/php-cassandra#using-preparation-and-data-binding
DataStax PHP Driver 分页参考:https://datastax.github.io/php-driver/features/result_paging/
分页参考:https://cwiki.apache.org/confluence/display/solr/Pagination+of+Results
最后一个链接虽然没看懂,但还是要谢谢一直帮我,寻找解决方式的 Nandan Priyadarshi !
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。