Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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;
}
Comment | File | Size | Author |
---|---|---|---|
#23 | 1442686-23--README.patch | 1.67 KB | drunken monkey |
#22 | 1442686-22--README.patch | 1.67 KB | drunken monkey |
#19 | 1442686-19--missing_pager.patch | 2.21 KB | drunken monkey |
Comments
Comment #1
andrewko CreditAttribution: andrewko commentedSo 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()?
Comment #2
atlea CreditAttribution: atlea commentedI'm experiencing the same - no pager! Did you find a way to resolve this?
Edit: This only seems to be true if logged in.
Comment #3
andrewko CreditAttribution: andrewko commentedI 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?
Comment #4
atlea CreditAttribution: atlea commentedNone that I can see..
I put this into a block using php-filter:
It returns just one key, 0, and the other values are correct (on page 0, 2 pages, 11 results).
Atle
Comment #5
andrewko CreditAttribution: andrewko commentedAre you using the fuzzy search module?
Comment #6
atlea CreditAttribution: atlea commentedNo..
Comment #7
andrewko CreditAttribution: andrewko commentedThen 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.
Comment #8
Murzandrewko, did you find any way how to fix this problem with fuzzy search?
Comment #9
andrewko CreditAttribution: andrewko commentedYes. My fuzzy search adventure is over in a Fuzzy Search issue: #1441630: Total count not right for paging
Comment #10
Murzandrewko, thanks, but that issue works only for views results, but I use output without views.
Comment #11
andrewko CreditAttribution: andrewko commentedI 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.
Comment #12
MurzHmm, commenting out string:
$results['result count'] = count($results['results']);
inincludes/service.inc
line 730 solves the issue.Comment #13
andrewko CreditAttribution: andrewko commentedYep. Looks like the same issue i ran in to. You should be good to go.
Comment #14
Alan D. CreditAttribution: Alan D. commentedInteresting, seems to be a number of reasons for this, mine was view panes in panel nodes :(
Comment #15
drunken monkeyI think this is fixed? Otherwise, please re-open!
Comment #17
scoff CreditAttribution: scoff commentedActually 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)
Comment #18
BBCThanks scoff, the views pager pager workarounds you suggested did the trick for me.
Comment #19
drunken monkeyYes, 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).
Comment #20
drunken monkeyCould someone who's having this problem please test the patch, to see if it fixes the problem?
Comment #21
scoff CreditAttribution: scoff commentedNope, 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.
Comment #22
drunken monkeyHm, 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.
Comment #23
drunken monkeyTypo.
Comment #24
drunken monkeyDocumentation patch committed.
Setting back to "active" since we might want to apply further fixes (if people not using Views complain).
Comment #24.0
drunken monkeyobfuscating my function
Comment #26
onepartscissors CreditAttribution: onepartscissors commented@andrewko in #3 you just saved me hours, THANK YOU!
Comment #27
ccpedro CreditAttribution: ccpedro commented#3 Show me the correct path to solve the problem. Thanks!!
Comment #28
drunken monkeyAfter four years, I think we can mark this as "Fixed".
Comment #30
mattbarnes CreditAttribution: mattbarnes as a volunteer commentedAfter 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.
Comment #31
Mitnick CreditAttribution: Mitnick commentedThank you, Matt! This fixed my problem.
Comment #32
GuyPaddock CreditAttribution: GuyPaddock at Inveniem commentedSo 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 :)