Search Module: InternalQuerier pagination doesn't work

Search Module is cool, even without solr behind, thanks to InternalQuerier implemented by @Daniel_KM.
Basic faceted filtering is allowed, enought for my project.

However, I have could see that pagination doesn’t work on InternalQuerier. Only show one page for first “1 to max_per_page” number of result. No more pages.

At file Search/src/Querier/InternalQuerier.php, line 158, has been fetched a response from

$apiResponse=$api->search($resourceType, $data, ['returnScalar' => 'id']);

This $apiResponse has “totalResults” value incorrect, being max result per page or less for any query, not real total results. Pagination is broken for this issue.

Though, calling without [‘returnScalar’ => ‘id’] option

$api->search($resourceType, $data)->getTotalResults();

Total results returned value is right.

I don’t know if returnScalar option is from Omeka S API or Zend framework, but with this value totalResults are miscounted.

Quick and dirty solution is launch query two times with diferent parameters allowing counting total results correctly:

From line 156 in InternalQuerier:


        foreach ($resourceTypes as $resourceType) {
        	$totalResults=0;
            try {
                $apiResponse = $api->search($resourceType, $data, ['returnScalar' => 'id']);
 		$totalResults = $api->search($resourceType, $data)->getTotalResults();
            } catch (\Omeka\Api\Exception\ExceptionInterface $e) {
                throw new QuerierException($e->getMessage(), $e->getCode(), $e);
            }

Pagination on faceted search works with this change.

@Daniel_KM, your repository https://github.com/Daniel-KM/Omeka-S-module-Search/ doesn’t have issue page, so I can’t report this issue there.

Thanks!