Index scan timed out

wrt the query:

SELECT SUBSTR(meta().id,0,POSITION(meta().id,"-")), COUNT(meta().id)
FROM cloud_med
GROUP BY SUBSTR(meta().id,0,POSITION(meta().id,"-"))

To do the grouping of the entire data set, we need to get the whole index data and then do the grouping.
There are couple of optimizations in CB 4.5 for you to exploit this by writing a small script:

SELECT phylum, COUNT(1) FROM bucket group by phylumn;

Step 1. SELECT min(phylum) from bucket where type = ‘blah’;
step 2: select count(1) from bucket where < full condition> AND phylum =
step 3: SELECT min(phylum) from bucket where type = ‘blah’ where phylum > “the previous value
step 4. repeat 2, 3 till you no longer get the min(phylum) value.
Now you have full result with least processing.

CB 4.5 optimizes some of the COUNT() and does a quick look up of MIN() using the index order.