Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Advanced Search is broken with Search API Solr 4.3.0. #37

Closed
rosiel opened this issue Sep 25, 2023 · 3 comments
Closed

[BUG] Advanced Search is broken with Search API Solr 4.3.0. #37

rosiel opened this issue Sep 25, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@rosiel
Copy link
Member

rosiel commented Sep 25, 2023

What steps does it take to reproduce the issue?

Using the advanced search block does not alter the solr query, resulting in the search input having no effect on the search results.

  • When does this issue occur?
    Any time using the advanced search suite of blocks.

Likely culprit: the hook_search_api_solr_converted_query_alter was deprecated and removed in Search API 4.3. It is no longer being processed. Handle the PostConvertedQueryEvent instead.

Source: https://git.drupalcode.org/project/search_api_solr/-/commit/cdf4b1fdc9731fd541bd5bb52ac832726546dfc3#18a19e34ea0d44dc6ff8f9b32f3c7849fff22a17_1932_1926

Solution: Use the PostConvertedQueryEvent instead.

@joshdentremont also came across this.

@rosiel rosiel added the bug Something isn't working label Sep 25, 2023
@joshdentremont
Copy link
Contributor

I just took a pass at this, following the instructions at https://www.drupal.org/docs/8/modules/search-api-solr/search-api-solr-howtos/how-to-replace-the-deprecated-hook-hook_search_api_solr_query_alter-with-prequeryevent

I was able to get the code to run, but the issue I'm running into is that you could modify the solarium query in the hook, but don't seem to be able to modify it in the event.

You can see my attempt at https://github.com/joshdentremont/advanced_search/blob/2.x/src/EventSubscriber/SolrQueryAlterEventSubscriber.php

The alterQuery() function edits the local $solarium_query variable that is passed to it, but I don't think it is then getting back to Solr.

@rosiel
Copy link
Member Author

rosiel commented Sep 26, 2023

Argh i didn't see your work till after I learned about how to make event handlers! Thank you! If you have the time it would be nice to have more eyes on my PR (i'm a little amazed it seems to work)

@joshdentremont
Copy link
Contributor

@rosiel it looks like we did the exact same thing except I used a different event than you, and it didn't work. Your fix works for me, thanks for putting this together so quickly.

@rosiel rosiel closed this as completed Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants