Setup

  • Solr version: 7.7.3
  • Drupal Core version: 8.9.16
  • Search API version:8.x-1.19
  • Search API Solr version:4.1.11
  • Configured Solr Connector: Acquia and Standard

Spellcheck suggestions returning concatenated/incorrect results

I tried setting up search_api_autcomplete with the search_api_solr module.
When checked for Solr Spellcheck option in autocomplete settings everything works fine except issues related to few terms where getting concatenated spellcheck suggestions. Also for misspelled phrases, the spellcheck suggestions are not appropriate.

Attaching screenshots.

Autocomplete settings
Autocomplete settings

Correct results when phrases are not misspelled
Autocomplete results with spelling mistake

Incorrect results when phrases are misspelled
Incorrect results when phrases are misspelled

Incorrect/concatenated results when single word is misspelled
Incorrect/concatenated results when single word is misspelled

Looks like something wrong with getAutocompleteSpellCheckSuggestions() method of SearchApiSolrBackend class.

Comments

sonu.raj.chauhan created an issue. See original summary.

sonu.raj.chauhan’s picture

Priority: Normal » Major
mkalkbrenner’s picture

Category: Bug report » Support request
Priority: Major » Normal

You should not mix "Retrieve from server" and "Solr Spellcheck".

The spellchecker can only return what is stored in the dictionary. So how did you configure the spell checker in the index field settings?

sonu.raj.chauhan’s picture

Hi @mkalkbrenner

Thanks for the suggestion. But even after disabling the `Retrieve from server` option, the issue remains the same.

However Search API spellcheck module suggestions are coming fine in search view fields.

Attaching Index field configuration for spellcheck field and solr backend schema configuration for spellcheck.

Index field configuration for Spellcheck
Index field config

Solr schema configuration for spellcheck
Solr schema config

Incorrect Phrase spellcheck autocomplete suggestion
incorrect phrase

Incorrect work spellcheck autocomplete suggestion
incorrect word

Correct Phrase and word spellcheck suggestion using Search API spellcheck views integration.
correct spellcheck
correct spellcheck

mkalkbrenner’s picture

First you should filter punctuation from the spellcheck field using the "ignore characters" processor.

In your screenshots I see spellcheck suggestions for the last word as flat list. The suggestions themselves for the last word are correct and expected spellchecker results.But the representation is wrong. Do you use any custom code here?

sonu.raj.chauhan’s picture

Hi @mkalkbrenner

Agreed. The suggestions are correct but in a flat list.
I haven't done any custom code for this.
But briefly looked into the code.
Can this be causing the issue

protected function getAutocompleteSpellCheckSuggestions(ResultInterface $result, SuggestionFactory $suggestion_factory) {
    $suggestions = [];
    foreach ($this->extractSpellCheckSuggestions($result) as $keys) {
      $suggestions[] = $suggestion_factory->createFromSuggestedKeys(implode(' ', $keys));
    }
    return $suggestions;
  }

Here the implode(' ', $keys) statement is what converting it into flat list.
I tried to change the code for testing to

protected function getAutocompleteSpellCheckSuggestions(ResultInterface $result, SuggestionFactory $suggestion_factory) {
    $suggestions = [];
    foreach ($this->extractSpellCheckSuggestions($result) as $keys) {
      foreach ($keys as $key) {
         $suggestions[] = $suggestion_factory->createFromSuggestedKeys($key);  
      }
      //  $suggestions[] = $suggestion_factory->createFromSuggestedKeys(implode(' ', $keys));
    }
    return $suggestions;
  }

and results were better.

However, I needed to confirm one thing as in
For this misspelled text "vaihtelu on täysin normaaliu" shouldn't we expect the suggestion like "vaihtelu on täysin normaalii" as against current suggestion which is "normaalii" ?

mkalkbrenner’s picture

Version: 4.1.1 » 4.x-dev
Category: Support request » Bug report

  • mkalkbrenner committed 83ebf18 on 4.x
    Issue #3222968 by sonu.raj.chauhan, mkalkbrenner: Spellcheck suggestions...
mkalkbrenner’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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