Subject: | Minor documentation error |
The example for searchNext reads -
$ns->search('transaction', $query);
if ($ns->searchResults->{totalPages} > 1) {
while ($ns->searchResults->{pageIndex} !=
$ns->searchResults->{totalPages}) {
for my $record (@{ $ns->searchResults->{recordList} }) {
my $internalId = $record->{recordInternalId};
print "Found record with internalId $internalId\n";
}
$ns->searchNext;
}
}
using this loop condition appears to miss the last page because
searchnext increments the pagenumber to equal
$ns->searchResults->{totalPages} on the penultimate iteration and the
last page is never processed.
Example:
if ($ns->searchResults->{totalPages} > 1) {
while ($ns->searchResults->{pageIndex} !=
$ns->searchResults->{totalPages}) {
print ("Using page ".$ns->searchResults->{pageIndex}." of
".$ns->searchResults->{totalPages}." total pages\n");
$ns->searchNext;
}
}
yields:
test:~# ./test.pl
Using page 1 of 4 total pages
Using page 2 of 4 total pages
Using page 3 of 4 total pages
test:~#
I have used the following which seems to work:
if ($ns->searchResults->{totalPages} > 1) {
do {
for my $record (@{ $ns->searchResults->{recordList} }) {
my $internalId = $record->{recordInternalId};
print "Found record with internalId $internalId\n";
} while ($ns->searchNext);
}
cheers,
Paul