Skip to content

Fix autocomplete hiding cross-language matches in "Any language" mode - #1935

Open
fvogel wants to merge 1 commit into
NatLibFi:mainfrom
fvogel:fix/autocomplete-unique-anylang
Open

fvogel wants to merge 1 commit into
NatLibFi:mainfrom
fvogel:fix/autocomplete-unique-anylang

Conversation

@fvogel

@fvogel fvogel commented Feb 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Autocomplete search always passes unique=true to the REST API, which deduplicates results by URI
  • When "Any language" is selected, this silently drops matches from other languages (e.g. French results hidden by Spanish ones for the same concept)
  • Fix: set unique=false when "Any language" is selected, unique=true otherwise

Steps to reproduce

  1. Set up a multilingual vocabulary (e.g. EN/FR/ES)
  2. Select "Any language" in the search dropdown
  3. Type a term that exists in multiple languages (e.g. restaur matching both Spanish "Restaurar..." and French "Restaurer...")
  4. Only results from one language appear; the other language matches are silently dropped

Fix

One-line change in resource/js/vocab-search.js: make unique conditional on whether a specific language is selected.

// Before:
const skosmosSearchUrlParams = new URLSearchParams({ query: this.formatSearchTerm(), unique: true })

// After:
const unique = this.selectedLanguage !== 'all'
const skosmosSearchUrlParams = new URLSearchParams({ query: this.formatSearchTerm(), unique: unique })

Before / After

Before (v3.1): Only Spanish (es) matches — French results silently dropped.

before

After (this fix): Both Spanish and French matches shown, as expected for "Any language" search.

after

Fixes #1934

The autocomplete search always passes unique=true to the REST API,
which deduplicates results by URI. When "Any language" is selected,
this silently drops matches from other languages (e.g. French results
hidden by Spanish ones for the same concept).

Make unique conditional: false when "Any language" is selected (so all
language matches are shown), true otherwise (to avoid same-language
duplicates).

Fixes NatLibFi#1934
@sonarqubecloud

Copy link
Copy Markdown

@osma osma moved this to Under review in Skosmos 3.x Backlog Mar 3, 2026
@osma

osma commented Mar 3, 2026

Copy link
Copy Markdown
Member

Thank you for identifying the issue and proposing a fix.

There is similar functionality for the global search bar and I think it needs to be changed as well:

const params = new URLSearchParams({ query: apiSearchTerm, unique: true })

To verify that the fix works today and stays working in the future, we would like to have Cypress tests that check for this case. Would it be possible for you to provide such tests? The tests could go into tests/cypress/template/vocab-search-bar.js and tests/cypress/template/global-search-bar.js, respectively.

You probably need a test vocabulary with a suitable test case. One of the test vocabularies is a small subset of YSO that contains the yso:p3358 concept which has the preflabels "systems"@en and "system"@sv, maybe you could use that?

@osma osma self-assigned this Mar 3, 2026
@osma osma moved this from Under review to Skosmos 3.x Backlog (not this sprint) in Skosmos 3.x Backlog Apr 14, 2026
@osma osma moved this from Skosmos 3.x Backlog (not this sprint) to Current sprint backlog in Skosmos 3.x Backlog Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Current sprint backlog

Development

Successfully merging this pull request may close these issues.

Autocomplete: show all language matches when searching 'Any language'

2 participants