This topic contains 2 replies, has 0 voices, and was last updated by chanarbon 7 years, 12 months ago.
-
AuthorPosts
-
November 17, 2016 at 4:19 pm #1522
tgrimmI am in the works of writing a combination of Suitelet calling a RESTlet which will return the results of a search. I have attempted this in SS 1.0 and now in SS 2.0 and continue to have the same issue. In the UI I can display 1000 search results in less than 4 seconds. When attempting to ‘get’ these sames results via code it takes nearly 30 seconds, longer for each iteration. The code is pretty simple. It accepts a search.Search object from another function and returns the full result set. It does this by getting the results 1000 at a time and concatenating them together. So far in my testing it appears to timeout at roughly 11000 results. The search I am testing with is a Time Entry search, contains no joins, and has 15 columns. It appears based on testing that each time the getRange() is called with a new start and end it takes longer and longer. Anyone else experience this or have a workaround?
Code:
function getFullResultSet(search) { //search is the search.Search objectvar tempResults,
resultSet,
results = null,
lastIndex = 0;resultSet = search.run();
do {
tempResults = resultSet.getRange({
start: lastIndex,
end: lastIndex + 1000
});
if (tempResults) {if (!results) {
results = [];
}results = results.concat(tempResults);
lastIndex += 1000;
}} while (tempResults && tempResults.length === 1000);
return results;
}
This is a cached copy. Click here to see the original post. -
November 17, 2016 at 4:44 pm #1523
david.smithI’ve done many of these types of interfaces. With SS2.0 we were given several ways to parse through search results. I have to warn everyone that using pageRanges and runPaged has given me inconsistent results and I no longer user it for many reasons.
Currently I use SearchObj.run().each(function(result) { when I can. You can pull up to 4,000 results with it at one time.
I do have another restlet that allows them to set the max number of results. Personally I’ve used it to pull over 30,000 results with a dozen or so columns. This was taking 20-30 seconds to return the data set.
-
November 23, 2016 at 9:49 am #1524
chanarbonFor this concern, I would suggest for you to use the Pagination search ni SuiteScript 2.0. Pagination search this would allow to to perform the pagination which is by ranges which will generally improve your script performance. Please see SuiteAnswers ID 49291
david.smith replied on 11/23/2016, 10:57 AM: This type of search in SS2.0 has problems. I have an active case open and one that was closed for another reason. If you use this type of pagination please check and verify your data!! It doesn’t always return the full set of search results.
-
AuthorPosts
You must be logged in to reply to this topic.