We are using an N1QL query which aggregates data using group by and sorts it by timestamp. It also uses offset and limit for pagination. To get the total number of records to the caller, we use the N1qlMetrics.sortCount().
Now, we are exploring the use of Map Reduce views to achieve the same behavior. I am using range keys (startKey, endKey) with skip and limit along with group and reduce (for aggregation) to fetch the required data. Is there an easy way to get the total number of records within my startKey and endKey similar to what is returned by the N1qlMetrics.sortCount() ?
Strangely ViewResult.totalRows() always returns zero, even though it is returning the correct number of records as per the limit mentioned in the ViewQuery.
We are using Couchbase 5.1 and Java SDK Client 2.5.6