I was running in to a problem where the pager wouldn't show up when I set up a view for search results I think I tracked it down to the search_api_views/includes/query.inc

It seems that the total results that come back from the query will always be the limit you set for the page or less, because the total count it's setting is from the results of the range query and not of a query that looks at all of the matches. I hope that makes sense.

On line 228
$this->query->range($this->offset, $this->limit);

On line 239:
$this->pager->total_items = $view->total_rows = $results['result count'];

The $results is the limited results so if you limit your pager to 10 results at a time then this will always return the 10 or less results this query returns.

Comments

andrewko’s picture

Component: Views integration » Framework

I guess this isn't really an issue with the views integration since the total count is coming from elsewhere (ie. where the query is running).

andrewko’s picture

Project: Search API » Fuzzy Search
Version: 7.x-1.0 » 7.x-1.x-dev
Component: Framework » Code

Moving to Fuzzy Search. It's not an issue with Search API.

andrewko’s picture

So it looks like Fuzzy search is setting the result count correctly at line 657 of service.inc and then resetting it to the limited query count at line 730.

dmegatool’s picture

Yeah the line is even commented just above it (line 727). I commented 730 and uncommented 728 and the pager started to work again... I don't get duplicate or what so ever.

// @todo figure out why  query is returning duplicates so we cant use:
$results['result count'] = $count_query->execute()->fetchField();

// $results['result count'] = count($results['results']);
andrewko’s picture

Title: Views total count not right when limiting » Total count not right for paging

Changing title to reflect the true issue

mbelos’s picture

#7 also seems to work for me.

wheelercreek’s picture

Just chiming in here - no pagination was appearing for me at all, and the fix on #7 worked for me. Not sure why that line was commented out.

awolfey’s picture

Status: Active » Fixed

Thanks dmegatool! Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

masher’s picture

Issue summary: View changes

Still experiencing this issue on the latest D7 dev release.

Other views pagers working fine on the same installation.

Apologies if this is another issue.