Problem/Motivation

In https://www.drupal.org/project/searchstax/issues/3537195, spellcheck wasn't working, but it was resolved with https://git.drupalcode.org/project/searchstax/-/commit/f25728ad4e400bef8.... In version 1.8.1, spellcheck is not working.

Steps to reproduce

  1. Set up a local Drupal 10 app using ddev and installed & enabled search_api, search_api_solr, and SearchStax modules
  2. Installed and enabled the search_api_spellcheck module
  3. Created a SearchStax Site Search app, created a server, index, and linked it to the app, and indexed the data
  4. Configured Searchstax settings and checked the box that says "Route all searches through SearchStudio" and also checked the "Spellcheck" option
  5. Created a Drupal Views search page with a Fulltext filter, and added the widget -> Global: Search API Spellcheck "Did You Mean" (Global: Search API Spellcheck "Did You Mean") to the Header of the search page
  6. Added a word "moore" to the SearchStax Spellcheck dictionary so that it's returned in the suggestions when I misspell it (works correctly on Site Search preview or in the SearchStax UI App (see #3502591: Include Searchstax UI App))

Proposed resolution

Restore functionality for spellcheck and update documentation explaining how to add spellcheck.

Issue fork searchstax-3561562

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nmillin created an issue. See original summary.

drunken monkey made their first commit to this issue’s fork.

drunken monkey’s picture

Version: 1.8.2 » 1.x-dev
Status: Active » Needs review

Thanks a lot for reporting this problem!
I could reproduce the issue and was able to identify the cause. This MR should fix the problem. I have already merged it to HEAD, but please give it a try and provide feedback on whether this works for you.
Once confirmed, this will be part of the next stable release.

  • drunken monkey committed 691304bf on 1.x
    fix: #3561562 Fixed spellcheck functionality for some setups.
    
    By:...
nmillin’s picture

Thanks @drunken monkey for looking at this!

I had a bad time using the patch (https://git.drupalcode.org/project/searchstax/-/merge_requests/63.patch) for this. spellcheck wasn't working. In poking at src/Service/SearchStax.php, it looks like a return is always hitting for me because I want Drupal's config to be used. The code in question:

      // Check whether we should also remove most search params set by Drupal
      // and simplify search keys so SearchStudio settings will take effect.
      if (!$config->get('configure_via_searchstudio')) {
        // Set the "defType=lucene" query parameter (unless the "defType"
        // parameter is already set).
        if (empty($solarium_query->getParams()['defType'])) {
          $solarium_query->addParam('defType', 'lucene');
        }
        return;
      }

If I comment out the return, it works! I get spellcheck again.

Is this return needed?

Thanks for all you do!

  • drunken monkey committed 93c049af on 1.x
    fix: #3561562 Fixed spellcheck functionality for some setups.
    
    By:...
drunken monkey’s picture

The return is needed if you want Drupal’s configs to be used, yes, otherwise you’ll get to the part of the code that discards parameters from the Solr query. If you want to have that, then you don’t need to change the code, you just need to enable the “Configure searches via SearchStudio” setting.

However, if spellcheck functionality isn’t working when that setting is disabled then that would of course still be an issue we need to investigate.

drunken monkey’s picture

Status: Needs review » Fixed

Marking this as fixed since this was now confirmed to be working properly. In case this is still not working for you, please file a separate ticket with more details on how to reproduce.

There is now also #3568022: Spellcheck does not ignore case, fixing a problem caused by this change.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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