Search code examples
phpcassandralucenecassandra-lucene-indexbigdata

PHP-CASSANDRA-LUCENE Paging with sorting


I am trying to fetch sorted records with paging in cassandra which is using lucene indexes for searching and sorting

Note : There are total 26 rows in user table

Case 1 : Sorting in ascending order with paging

cqlsh > paging 10;
cqlsh > SELECT user_id FROM user WHERE category_id = 'e4da3b7f-bbce-2345-d777-2b0674a318d5' AND expr(user_index, '{filter:[{type:"match", field:"is_primary", value:true}], sort:[{field: "user_id",reverse:false}]}');

This will give all 26 rows in ascending order of user_id first 10 rows,second 10 rows then last 6 rows that is fine but issue in case 2

Case 2 : Sorting in descending order with paging

cqlsh > paging 10;
cqlsh > SELECT user_id FROM user WHERE category_id = 'e4da3b7f-bbce-2345-d777-2b0674a318d5' AND expr(user_index, '{filter:[{type:"match", field:"is_primary", value:true}], sort:[{field: "user_id",reverse:true}]}');

This will give only 19 rows in descending order of user_id first 10 rows,then 9 rows same of first page

Is this indicate that cassandra paging and lucene sorting can't use together? If yes then any alternative to use sorting on lucen indexes with cassandra paging? While answering please consider timeline based sorting and paging can't apply here because I have to consider too many columns while sorting.


Solution

  • Paging and sorting should work together. Which version of both Apache Cassandra and the Lucene index plugin are you using?

    Could you please provide the table and index creation statements and the rows returned by each query? The values of user_id and mac_address would be enough to reproduce the issue.