It is possible to change the number of displayed rows via hook_apachesolr_modify_query:

function MODULENAME_apachesolr_modify_query(&$query, &$params, $caller) {
  $page = $params['rows'] ? $params['start'] / $params['rows'] : 0;
  $params['rows'] = 12;
  $params['start'] = $page * $params['rows'];
}

That works. If I have 1000 results, I would have 84 pages (ceil(1000 / 12)), but the pager still displays 100 pages (this is based on the default setting of 10 results per page). Clicking the last link in the pager leads to a page which says that there are not search results.

The patch attached changes apachesolr_search_execute to pass $params as a reference to apachesolr_do_query (which will indirectly invoke the modify query hooks).

The changed params are passed to apachesolr_process_response, where the pager is going to be initialized, now always with the correct number of rows.

CommentFileSizeAuthor
apachesolr_pager.patch692 bytesmauritsl

Comments

pwolanin’s picture

Status: Needs review » Needs work

seem like do_query should specify that the params are by reference? I think you have this backward.

jpmckinney’s picture

mauritsl’s picture

Status: Needs work » Closed (duplicate)

Yes, it will be fixed by that patch. Closing this issue as a duplicate.