Many queries have the potential for returning large result sets. Most applications don’t want to display the entire result set - they may want to display just the first 10 results. Or they may want to page through the results, showing results 0-9, then results 10-19, etc.

The RANGE directive is used to specify this in the RQL query. The RANGE directive must come after the ORDER BY directive (if any). It has three forms. The first is the most common:

age > 30 RANGE +10

This causes only the first 10 results to be returned. If the result set is already less than 10, then all of the results are returned.

The next form of the RANGE directive allows the results to start at a specified index:

age > 30 RANGE 10+

This causes the first 10 results to be skipped, and the remaining results to be returned.

The final form of the RANGE directive combines the above two forms, and is often used for paging:

age > 30 RANGE 40+10

This skips the first 40 results, then returns up to the next 10 results.

 
loading table of contents...