Limiting results and paging

DSE Search integrates native driver paging with Apache Solr™ cursor-based paging. Pagination, also called cursors, supports using a cursor to scan results. Solr pagination restrictions apply.

When using CQL Solr queries with pagination enabled, you might experience a performance slowdown because Solr is not able to use its query result cache when pagination is configured. If you do not want to paginate through large result sets, disable pagination when running CQL Solr queries. See the driver documentation.

Using pagination (cursors) with CQL Solr queries

In dse.yaml, the cql_solr_query_paging option specifies when to use pagination (also called cursors):

  • When a driver connects to the database and executes a CQL SELECT statement using a search index (solr_query option), you can specify to use the driver pagination settings by default by changing the cql_solr_query_paging to driver.

  • To enable pagination persistently with CQL Solr queries, set cql_solr_query_paging: on in dse.yaml and restart the node.

    To dynamically enable pagination when cql_solr_query_paging: off in dse.yaml, use the "paging":"driver" parameter:

    select id from wiki.solr where solr_query='{"q":"*", "sort":"id asc", "paging":"driver"}';

SearchAnalytics nodes always use driver paging settings. See DSE Analytics and Search integration.

See the documentation for the CQL shell command and the driver.

It is not mandatory to use a sort clause. However, if a sort clause is not provided, sorting is undefined.

Examples

The word Journal is contained in ~159 entries in the body or title. Use count to determine how many rows match:

SELECT count(*) FROM wiki.solr WHERE solr_query = 'Journal';

Count returns only a single row; it is not effected by the 10 row limit.

 count
-------
   159

(1 rows)

Run the same query without count (and cql_solr_query_paging: off):

SELECT id FROM wiki.solr WHERE solr_query = 'Journal';

Only 10 rows are returned.

 id
----------
 23759487
 23732986
 23759527
 23759551
 23759455
 23760810
 23731949
 23760697
 23760871
 23738270

(10 rows)

To return all matching IDs, override the cql_solr_query_paging setting:

SELECT id FROM wiki.solr
WHERE solr_query='{"q":"Journal", "paging":"driver"}';

If cqlsh PAGING is enabled.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com