Autosuggest terms always display for the default language for multi-lingual setup

Created on 17 July 2025, 17 days ago

Problem/Motivation

After installing the SearchStax module in Drupal, and routing searches through it, the Auto-suggest dropdown keeps displaying the default language suggestions when searching for a term in the language's Search view, even when multiple languages are configured. For example, if EN (default) and FR are the 2 languages, then searching on drupal-site/en/search will show the same suggestions as searching on drupal-site/fr/search, which will be the terms configured for EN (default) language on SearchStax.

From my understanding so far, this happens because within the SearchStax module code, the language param isn't being passed to the /emsuggest query.

Steps to reproduce

  1. Create a Drupal app and connect to SearchStax.
  2. Install and enable the SearchStax module on Drupal.
  3. Enable search_api, search_api_autocomplete, and search_api_solr for the Auto-complete feature to work.
  4. Under Configuration > Search and metadata > SearchStax settings, check the boxes which say "Re-route searches through SearchStudio" and "Configure searches via SearchStudio". Add the Auto-suggest core and click on "Save configuration".
  5. On SearchStax Site Search dashboard, go to App Settings > Languages and add a second language besides EN.
  6. Create a Search view on Drupal and populate content for testing. Index the data and enable Auto-suggest on SearchStax Site Search dashboard by going to Recommendations > Auto-suggest > Enable Auto-Suggest > Save Draft > Publish.
  7. Add different sets of suggestion terms under the 2 languages. For example, if the 2 languages configured are EN and FR, we can add "sammy" for EN and "samuel" for FR. This will help test the autosuggestions if we search for "sa"
  8. On Drupal, under Configuration > Search and metadata > Search API, select the index, then go to the "Autocomplete" section.
  9. Check the "Search" box, then click on "Edit". Check "SearchStax" under "Enabled suggesters", and hit "Save".
  10. Go to the Search view for each language, and start typing the common start letters. The suggestions that show up for both languages will be the one that's set to default (in my testing, it was EN so even for FR language, I was seeing EN suggestions).

Proposed resolution

If the language code for the language currently selected by the user on Drupal is passed to the /emsuggest params, we'll get the correct autocomplete suggestions for the corresponding language.

As a workaround, I tried adding the language parameter to the /emsuggest query after fetching the current language id, and then I was able to get different suggestions for the different languages.

I've attached a patch with the changes I made to the following file for this workaround, in case it is helpful for reference:
web/modules/contrib/searchstax/src/Plugin/search_api_autocomplete/suggester/SearchstaxSuggester.php

🐛 Bug report
Status

Active

Version

1.7

Component

General code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024