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.
Problem/Motivation
I want to display my search facets on every page of my website, so I went to the the facet configuration and enabled the "Display Facets on non-search page" checkbox.
As a path I entered * since my pages are all at the root of the website.
It seems like there's some kind of conflict somewhere as when I do this the search will ALWAYS retun empty result, whatever I choose (facets) or search.
When I only enter it works great.
I believe that you should use the same kind of pages selection as Blocks :
- Display only on selected pages
- Display on everypage except the selected ones
Thanks!
Comment | File | Size | Author |
---|---|---|---|
#8 | 1965204-8-D6x-3x.patch | 556 bytes | jantoine |
#7 | 1965204-7-D6x-3x.patch | 1.96 KB | pwolanin |
#6 | 1965204-6.patch | 1.97 KB | pwolanin |
#4 | apachesolr_prevent-empty-search-1965204-4.patch | 754 bytes | jantoine |
#3 | apachesolr-prevent_empty_search-1965204-3.patch | 769 bytes | jantoine |
Comments
Comment #1
Growiel CreditAttribution: Growiel commentedStill a problem as of the last version of the dev build.
Anybody as pointers how to fix this ? I really need it for a project, it's blocking for me.
Comment #2
jantoine CreditAttribution: jantoine commentedI am also seeing this issue with both the 7.x-1.x and 6.x-3.x branches. I noticed that with the 6.x-3.x branch, the issue goes away if I leave the "Submit Search block requests to this page" set to use Drupal's derfault search page. As soon as I set it to an Apache-Solr search page, the issue comes back (no results).
Comment #3
jantoine CreditAttribution: jantoine commentedThe problem boils down to the caching of the empty search query. This empty query is what allows facets to show up on non-search pages. When you visit a search page, the empty query has already been run and cached resulting in no results being sent to the search page results.
Attached is a patch for the 6.x-3.x branch that prevents the empty search query from running when on the default search page.
Comment #4
jantoine CreditAttribution: jantoine commentedSame patch in #3, but for the 7.x-1.x branch.
Comment #5
jantoine CreditAttribution: jantoine commented#3: apachesolr-prevent_empty_search-1965204-3.patch queued for re-testing.
Comment #6
pwolanin CreditAttribution: pwolanin commentedI found a couple other needed fixes as well. The query was often running 2x.
it would run 2x if the path had no alias, and would also run 2x if the aliased and non-aliased path has a common prefix that matched the filter.
Comment #7
pwolanin CreditAttribution: pwolanin commentedcommitted the above to 7.x, committed the attached patch to 6.x-3.x
Comment #8
jantoine CreditAttribution: jantoine commentedPatch in #7 introduces PHP error trying to call the D7 current_path() function in a D6 environment. Attached patch fixes this.
Comment #9
wonder95 CreditAttribution: wonder95 commentedThere is a problem with the patch in #7 above, in that it relies on the current_path() function, and that is a D7 only function. This was already fixed back at #1547672: apachesolr_search.module - line 27 - current_path should be replaced with $_GET['q'].
Comment #10
pwolanin CreditAttribution: pwolanin commentedFixed that in 6.x, sorry for the editing fail