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.

Comments

ericgsmith created an issue. See original summary.

ericgsmith’s picture

Status: Active » Needs review
StatusFileSize
new922 bytes

Attached is a patch using the existing configuration option

ericgsmith’s picture

StatusFileSize
new922 bytes

Attaching with corrected filename

ericgsmith’s picture

Issue summary: View changes
mkalkbrenner’s picture

StatusFileSize
new1.97 KB

Thanks for opening this issue.

I tried to solve it differently to have a better performance. Can you test it?

ericgsmith’s picture

Hello, 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"

mkalkbrenner’s picture

StatusFileSize
new2.05 KB

Thanks for the feedback. Here's an update.

ericgsmith’s picture

Status: Needs review » Reviewed & tested by the community

Thanks - 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.

  • mkalkbrenner committed 1645260 on 4.x
    Issue #3324436 by ericgsmith, mkalkbrenner: Spellcheck dictionary should...
  • mkalkbrenner committed 44ed2fb on 4.x
    Issue #3324436 by ericgsmith, mkalkbrenner: Spellcheck dictionary should...
mkalkbrenner’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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