Unable to parse Fulltext search indexes

Created on 3 February 2023, almost 2 years ago
Updated 17 October 2023, about 1 year ago

I have search_api_solr 4.2.1 and a large Fulltext search index

The index works fine via Solr, but I'm unable to use it with the Spellcheck module. I get the following error:

InvalidArgumentException: The selected parse mode for fulltext fields is not compatible to Search API Spellcheck. in Drupal\search_api_spellcheck\Plugin\views\area\DidYouMeanSpellCheck->query() (line 66 of search_api_spellcheck/src/Plugin/views/area/DidYouMeanSpellCheck.php).

An exception is being thrown in

 public function query() {
    if (
      $this->query instanceof SearchApiQuery &&
      $this->query->getIndex()->getServerInstance()->supportsFeature('search_api_spellcheck')
    ) {
      $keys = $this->query->getKeys();
      // Don't set the option if $keys is NULL.
      if ($keys) {
        if (!is_array($keys)) {
          throw new \InvalidArgumentException('The selected parse mode for fulltext fields is not compatible to Search API Spellcheck.');
        }
        $this->query->setOption('search_api_spellcheck', [
          // Strip non numeric array keys like '#collation'.
          'keys' => array_filter($keys, 'is_int', ARRAY_FILTER_USE_KEY),
          // This parameter specifies the maximum number of suggestions that the
          // spellchecker should return for a term.
          'count' => $this->options['search_api_spellcheck_count'],
          // If true and the backend supports it, this parameter directs the
          // backend to take the best suggestion for each token (if one exists)
          // and construct a new query from the suggestions. For example, if the
          // input query was "jawa class lording" and the best suggestion for
          // "jawa" was "java" and "lording" was "loading", then the resulting
          // collation would be "java class loading".
          'collate' => $this->options['search_api_spellcheck_collate'],
        ]);
      }
    }
    parent::query();
  }

Not sure if this is a bug (possibly related to Support setting parse mode and conjunction for fulltext conditions Active ) or need to raise a feature request... or something else to be done to utilise this module...

💬 Support request
Status

Closed: won't fix

Version

4.0

Component

Code

Created by

🇬🇧United Kingdom robcarr Perthshire, Scotland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @robcarr
  • 🇮🇳India milindk

    I also faced this issue. The problem is with the Direct parse mode is not supported by spellcheck. You have to change the parse mode to Multiple word or Sigle phrase to make it work.

    Steps:
    1. Edit view fulltext exposed field.
    2. Update the Parse mode to Multiple word or Sigle phrase.
    3. Save the view.

  • Status changed to Closed: won't fix about 1 year ago
  • 🇬🇧United Kingdom robcarr Perthshire, Scotland

    Thanks very much @milindk - I should have thought about altering the parse mode

Production build 0.71.5 2024