I'm using getRange() to get the results of saved searches.
It appears for certain ranges of numbers the search erroneously returns zero results. There is no error message thrown that I can see. The broken range returns more quickly than the searches that contain results.
I ran searches w/ different ranges and output the count (number of rows returned) for each start/end range:
{start: 0, end: 1000, count: 1000} // results w/ count of 1000 look OK
{start: 1000, end: 2000, count: 1000}
{start: 2000, end: 3000, count: 1000}
{start: 3000, end: 4000, count: 1000}
{start: 4000, end: 5000, count: 1000}
{start: 5000, end: 6000, count: 1000}
{start: 6000, end: 7000, count: 1000}
{start: 7000, end: 8000, count: 1000}
{start: 8000, end: 9000, count: 1000}
{start: 9000, end: 10000, count: 0} // Why is this count zero?
{start: 10000, end: 11000, count: 1000}
{start: 11000, end: 12000, count: 1000}
{start: 12000, end: 13000, count: 1000}
{start: 13000, end: 14000, count: 1000}
{start: 14000, end: 15000, count: 1000}
{start: 15000, end: 16000, count: 1000}
{start: 16000, end: 17000, count: 1000}
{start: 17000, end: 18000, count: 1000}
{start: 18000, end: 19000, count: 1000}
{start: 19000, end: 20000, count: 1000}
{start: 20000, end: 21000, count: 1000}
{start: 21000, end: 22000, count: 1000}
{start: 22000, end: 23000, count: 1000}
{start: 23000, end: 24000, count: 1000}
{start: 24000, end: 25000, count: 1000}
{start: 25000, end: 26000, count: 1000}
{start: 26000, end: 27000, count: 1000}
{start: 27000, end: 28000, count: 1000}
{start: 28000, end: 29000, count: 1000}
{start: 29000, end: 30000, count: 1000}
Trying to narrow things down, I did a few more specific searches near the 9000 - 10000 range and these are the results:
{start: 8999, end: 9999, count: 1000} // Seems OK just under 10,000
{start: 9000, end: 9999, count: 999}
{start: 9000, end: 10000, count: 0} // But then zero when 10,000 is reached
{start: 9001, end: 10001, count: 0}
{start: 9950, end: 10950, count: 0}
{start: 9999, end: 10999, count: 0}
[FONT=courier new]{start: 10000, end: 11000, count: 1000}
I have tested this on multiple saved searches of different types (Item and Transaction searches) and gotten the same results.[/FONT]
Including the contents of the RESTlet script below:
<span style="font-family:'courier new'"><span style="color:'#262626'">/**</span> <span style="color:'#262626'">* @NApiVersion 2.x</span> <span style="color:'#262626'">* @NScriptType Restlet</span> <span style="color:'#262626'">*/</span> <span style="color:'#262626'">define(['N/search', 'N/error'],</span> <span style="color:'#262626'"> function(search, error){</span> <span style="color:'#262626'"> function savedSearchResults(search_id, start, end){</span> <span style="color:'#262626'"> var ss = search.load({id: search_id}),</span> <span style="color:'#262626'"> rs = ss.run(),</span> <span style="color:'#262626'"> results = rs.getRange({start: start, end: end});</span> <span style="color:'#262626'"> return {results: results};</span> <span style="color:'#262626'"> }</span> <span style="color:'#262626'"> return {</span> <span style="color:'#262626'"> get: function(context){ return savedSearchResults(context.search_id, context.start, context.end); },</span> <span style="color:'#262626'"> delete: function(){ },</span> <span style="color:'#262626'"> post: function(){ },</span> <span style="color:'#262626'"> put: function(){ },</span> <span style="color:'#262626'"> };</span> <span style="color:'#262626'">});</span></span>