I have a search page set up and it shows that it found over 4k results, but no pager is shown. Am I missing something?

Here's my feature export:

function fuzzy_search_default_search_api_page() {
  $items = array();
  $items['fuzzy_search'] = entity_import('search_api_page', '{
    "index_id" : "default_fuzzysearch_index",
    "path" : "fsearch",
    "name" : "Search",
    "machine_name" : "fuzzy_search",
    "description" : "",
    "options" : {
      "mode" : "terms",
      "fields" : [],
      "per_page" : "10",
      "get_per_page" : 1,
      "view_mode" : "search_api_page_result"
    },
    "enabled" : "1",
    "rdf_mapping" : []
  }');
  return $items;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andrewko’s picture

So it looks like there was another pager on the same page and got conflicted. Is there a better way to initialize a pager than pager_default_initialize()?

atlea’s picture

I'm experiencing the same - no pager! Did you find a way to resolve this?

Edit: This only seems to be true if logged in.

andrewko’s picture

I had an unrelated view block that had the pager turned on. But that block didn't need a pager so I turned it off so the only pager on the page was the search pager. That solved my problem. Do you know if you have any other pagers going on the search results page?

atlea’s picture

None that I can see..

I put this into a block using php-filter:

global $pager_page_array, $pager_total, $pager_total_items;
print_r($pager_page_array);
print_r( $pager_total);
print_r( $pager_total_items);

It returns just one key, 0, and the other values are correct (on page 0, 2 pages, 11 results).

Array ( [0] => 0 )
Array ( [0] => 2 )
Array ( [0] => 11 ) 

Atle

andrewko’s picture

Are you using the fuzzy search module?

atlea’s picture

No..

andrewko’s picture

Then I'm at a loss. I had another problem with Fuzzy Search plugin where it only returned 10 as the total number of results no matter what, so the pager wouldn't show up. If you are using a search api plugin module, then I would check in that module's issues.

Murz’s picture

andrewko, did you find any way how to fix this problem with fuzzy search?

andrewko’s picture

Yes. My fuzzy search adventure is over in a Fuzzy Search issue: #1441630: Total count not right for paging

Murz’s picture

andrewko, thanks, but that issue works only for views results, but I use output without views.

andrewko’s picture

I should have changed the title of that issue sooner. It turned out to have nothing to do with views as it applied to search pages as well. Try the fix by dmegatool in comment #7.

Murz’s picture

Status: Active » Needs review

Hmm, commenting out string: $results['result count'] = count($results['results']); in includes/service.inc line 730 solves the issue.

andrewko’s picture

Yep. Looks like the same issue i ran in to. You should be good to go.

Alan D.’s picture

Interesting, seems to be a number of reasons for this, mine was view panes in panel nodes :(

drunken monkey’s picture

Status: Needs review » Fixed

I think this is fixed? Otherwise, please re-open!

Status: Fixed » Closed (fixed)

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

scoff’s picture

Version: 7.x-1.0-beta2 » 7.x-1.0-rc1
Status: Closed (fixed) » Active

Actually i'm not sure it's fixed in 7.x-1.0-rc1.

"The search found 695 results in 0.007 seconds." and I only got one page.

The source of this problem is a views block with a pager, even if it's not visible (i.e. block displays 30 items and "per page" is set to 100)

Workarounds:

— Disabling views pager brings search results paging back.
— Changing views pager ID to something other than 0 brings search results paging back.

I don't know if there's a way to predict/check/fix it. I do know that multiple views blocks with pagers work along without any issues (using same default ID = 0 in every view)

BBC’s picture

Thanks scoff, the views pager pager workarounds you suggested did the trick for me.

drunken monkey’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev
Category: support » bug
Status: Active » Needs review
FileSize
2.21 KB

Yes, thanks a lot for posting this, and for re-opening! Based on this information I came up with a patch which might help with this in some situations. On the whole, I think Drupal's paging system is just a little bit ill-equipped for more than one pager, but this workaround should at least take care of all pagers created before the search is shown. There's hardly anything we can do for the others (except maybe add some altering magic, but that's probably out of scope).

drunken monkey’s picture

Could someone who's having this problem please test the patch, to see if it fixes the problem?

scoff’s picture

Nope, sorry, patch #19 doesn't fix it.

1. Changed a view block back to paged and search pager's gone.
2. Applied the patch, still no pager.
3. drush cc all (just in case) — no pager
4. Reverted the view back to "show all results" and pager is back.

drunken monkey’s picture

FileSize
1.67 KB

Hm, OK, thanks. Your view block is probably rendered after the search page, so it wouldn't work. But at least for Views, you can always just set Views' pager element directly, thus making any special handling in this module unnecessary.

I guess there are only few situations in which a non-Views pager will be present on a search page. Still, fixing this some way would be nice.
What we could do, of course, is make the pager element for search pages configurable, too. Might be a bit overkill, especially since 99% of users will never want/need to use this, but it would definitely at least give users the power to fix this, once they've realized what's going on.

Or, does anyone here have this problem with a non-Views pager? Otherwise, maybe just adding a note in the README would suffice …
I guess we should add that anyways, if we end up making the element configurable, we can edit it to reflect that. But users should still made aware of this problem, so they'll realize what's going on instead of being just clueless. So, documentation patch attached.

drunken monkey’s picture

FileSize
1.67 KB

Typo.

drunken monkey’s picture

Status: Needs review » Active

Documentation patch committed.
Setting back to "active" since we might want to apply further fixes (if people not using Views complain).

drunken monkey’s picture

Issue summary: View changes

obfuscating my function

onepartscissors’s picture

Issue summary: View changes

@andrewko in #3 you just saved me hours, THANK YOU!

ccpedro’s picture

#3 Show me the correct path to solve the problem. Thanks!!

drunken monkey’s picture

Status: Active » Fixed

After four years, I think we can mark this as "Fixed".

Status: Fixed » Closed (fixed)

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

mattbarnes’s picture

After wrestling with this issue for hours, I wanted to contribute my use case for others' benefit.

At first I didn't think the second pager condition discussed above applied to my site, because there were no other blocks with paging on my search page (in fact, there were no views blocks on my search page at all).

However, there was a carousel on the homepage that uses paging. And even though neither its block nor its region were being rendered anywhere besides the homepage, its block was set to display on all pages, and that was enough to interfere with the search results paging. Changing the carousel block's settings to only display on the homepage made the search results paging work as expected.

Mitnick’s picture

Thank you, Matt! This fixed my problem.

GuyPaddock’s picture

So happy I found this thread. I was programmatically executing a view under the hood and had pagination turned on for that view inadvertently. Since the view gets executed on every page -- even though it's not visible -- it caused my Search API pagers to disappear.

Now that I disabled pagination, it's fixed :)