Setup
- Solr version: 8.11.2
- Drupal Core version: 9.4.8
- Search API version: 8.x-1.28
- Search API Solr version: 4.2.9
- Configured Solr Connector: Standard
Issue
Search suggestions are only populated using the 'en' dictionary for searches that include both 'en' and 'und' languages.
We have a search index configured with "Include language independent content in search results." in order to show both English and language not specified content. This works as expected when searching for content.
We also have the search_api_spellcheck module enabled - but the search suggestions being returned from solr are only coming from English content. I believe since we have "Include language independent content in search results" checked - we should also see suggestions coming from content with language not specified.
Steps to reproduce
Additional setup
- Index configured with "Include language independent content in search results."
- Search view configured with search_api_spellcheck_did_you_mean from search_api_spellcheck module
- Search view configured with no language filter applied
- Content with langcode und indexed
- Content with langcode en (or another language) indexed
Proposed resolution
When `setSpellcheck` is called the module is using the intersect of `$this->getSchemaLanguageStatistics()` and the langcodes returned from`Utility::ensureLanguageCondition($query)` to determine the dictionary to apply.
From what I can understand from the method getSchemaLanguageStatistics - that is correct in not returning und.
I think there should be an additional check on the include_language_independent to also include this if it is returned on the query object.
E.g. in our example we can see:
$this->getSchemaLanguageStatistics()
array (
'en' => 'en',
)
$query->getLanguages();
array (
0 => 'en',
1 => 'und',
)
And so the current logic only applies the 'en' dictionary.
I note that from this issue https://www.drupal.org/project/search_api_solr/issues/3081598 that this could potentially cause issues for certain languages - so may be better applied as an additional setting under the multilingual options.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3324436.patch | 2.05 KB | mkalkbrenner |
| #5 | 3324436.patch | 1.97 KB | mkalkbrenner |
| #3 | search_api_solr-spellcheck-dictionary-und-3324436-3.patch | 922 bytes | ericgsmith |
Comments
Comment #2
ericgsmith commentedAttached is a patch using the existing configuration option
Comment #3
ericgsmith commentedAttaching with corrected filename
Comment #4
ericgsmith commentedComment #5
mkalkbrennerThanks for opening this issue.
I tried to solve it differently to have a better performance. Can you test it?
Comment #6
ericgsmith commentedHello, thanks for the quick response.
The patch works well for the issue, I can see 'und' is now returned from getSchemaLanguageStatistics and the suggestions show for both languages.
There is a side effect that this introduces a warning in the status update page for incomplete scheme for LANGCODE_NOT_APPLICABLE / zzx.
"Schema incomplete
There are some language-specific field types missing in schema of index sitewide search on server Solr: zxx. These languages will use the language-undefined fallback field type"
Comment #7
mkalkbrennerThanks for the feedback. Here's an update.
Comment #8
ericgsmith commentedThanks - I've tested that and can confirm the patch is still working and there is no longer any additional messages on the status report.
Thank you!
Setting to RTBC - note that I have only tested this with en / und language combination.
Comment #10
mkalkbrenner