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

Correct results when phrases are not misspelled

Incorrect results when phrases are misspelled

Incorrect/concatenated results when single word is misspelled

Looks like something wrong with getAutocompleteSpellCheckSuggestions() method of SearchApiSolrBackend class.
Comments
Comment #2
sonu.raj.chauhan commentedComment #3
mkalkbrennerYou 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?
Comment #4
sonu.raj.chauhan commentedHi @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

Solr schema configuration for spellcheck

Incorrect Phrase spellcheck autocomplete suggestion

Incorrect work spellcheck autocomplete suggestion

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


Comment #5
mkalkbrennerFirst 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?
Comment #6
sonu.raj.chauhan commentedHi @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
Here the implode(' ', $keys) statement is what converting it into flat list.
I tried to change the code for testing to
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" ?
Comment #7
mkalkbrennerComment #9
mkalkbrenner