Problem/Motivation

The Snowball stemmer processor is only available in Search API index if English is one of the site languages.

Steps to reproduce

  1. Delete English from the list of used languages
  2. Configure processors for your Search API index
  3. Snowball stemmer is not available in the list

Proposed resolution

Override Drupal\search_api\Plugin\search_api\processor\Stemmer::supportsIndex() in plugin class to make processor available for all languages.

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

Thomas Bosviel created an issue. See original summary.

thomas bosviel’s picture

Issue summary: View changes

thomas bosviel’s picture

ekes’s picture

This would make the processor always visible even when there is no supported language. Looking at the inherited class it has:

  /**
   * {@inheritdoc}
   */
  public static function supportsIndex(IndexInterface $index): bool {
    $languages = \Drupal::languageManager()->getLanguages();
    // Make processor available only if English is one of the site languages.
    foreach ($languages as $language) {
      if (substr($language->getId(), 0, 2) === 'en') {
        return TRUE;
      }
    }
    return FALSE;
  }

So something similar but requesting the language from the stemmer class and if one is matched returning TRUE might make the most sense? Related to looking up languages that are available: #3270721: Does not work with Norwegian, Norwegian and Portuguese differing language codes.

ekes’s picture

Status: Active » Needs review

I've pushed a fix for this, checking the available languages, into the 2.x branch.

If someone wants to test, for example by `composer require drupal/snowball_stemmer:2.x-dev` and confirm I'll make a new release.

asterovim’s picture

Hello ekes. I confirm, the patch work's ! thanks you.

ekes’s picture

Status: Needs review » Fixed

@Asterovim thanks for the review. It's in the 2.1.0 release.

Status: Fixed » Closed (fixed)

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