line 152 : int size = max - first + 1 < 0 ? 0 : max - first + 1;
will produce wrong size, because max( first, queryHits.totalHits ) returns not the size of the selection but the max element index so for 3 hits max=2. And since first element is 1 and not 0 we have to account for it.
Correct size calculation: line 152 : int size = max - first + 2 < 0 ? 0 : max - first + 2;
Activity
Show:
Sanne GrinoveroFebruary 15, 2009 at 3:10 PM
The code is ok in my opinion; If you still think it's wrong please open a new JIRA providing a testcase. thanks
Sanne GrinoveroFebruary 15, 2009 at 2:32 AM
it looks like to me the first element is 0, not 1?
line 152 : int size = max - first + 1 < 0 ? 0 : max - first + 1;
will produce wrong size, because max( first, queryHits.totalHits ) returns not the size of the selection but the max element index so for 3 hits max=2.
And since first element is 1 and not 0 we have to account for it.
Correct size calculation:
line 152 : int size = max - first + 2 < 0 ? 0 : max - first + 2;