Skip to content

test(search): add non-English language coverage for FT.SEARCH#3339

Merged
nkaradzhov merged 2 commits into
redis:masterfrom
nkaradzhov:test/search-non-english-languages
Jul 21, 2026
Merged

test(search): add non-English language coverage for FT.SEARCH#3339
nkaradzhov merged 2 commits into
redis:masterfrom
nkaradzhov:test/search-non-english-languages

Conversation

@nkaradzhov

@nkaradzhov nkaradzhov commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

This pull request adds integration tests covering RediSearch behavior for languages other than English. The LANGUAGE and LANGUAGE_FIELD options on FT.CREATE/FT.SEARCH already had argument-encoding tests, but no test exercised the actual stemming/tokenization behavior against a live server.

The new non-English languages block in SEARCH.spec.ts verifies:

  • Language-specific stemming for German, French, Spanish, Greek, and Indonesian — an index built with the matching language's Snowball stemmer matches a different inflection of the query word, while an English-stemmed index over the same document does not.
  • Query-time LANGUAGE — the explicit query-side language option is accepted and yields the expected match.
  • Chinese tokenization — the friso tokenizer segments un-spaced text so a sub-term matches, whereas the default tokenizer does not.
  • Per-document LANGUAGE_FIELD — documents are stemmed according to their own language field, so a German query and a French query each match only their respective document.

Test-only change; no runtime behavior is affected. Runs on the default 8.10 test image (Indonesian stemmer requires 8.9.0+).

🤖 Generated with Claude Code


Note

Low Risk
Scope is integration tests plus widened TypeScript types for create options; runtime command behavior is unchanged.

Overview
Adds live-server integration tests for non-English RediSearch behavior and tightens FT.CREATE typings so hash field names work for language/score metadata.

The new non-English languages block in SEARCH.spec.ts checks that language-specific Snowball stemming matches inflected text (German, French, Spanish, Greek, Indonesian) while an English index over the same doc does not, that query-time LANGUAGE behaves the same, that Chinese tokenization matches a sub-term in unsegmented text, and that LANGUAGE_FIELD (__lang) stems each document with its own language.

In CREATE.ts, introduces RediSearchAttribute and uses it for LANGUAGE_FIELD and SCORE_FIELD so plain hash fields (e.g. __lang) type-check alongside @/$. properties—no command encoding changes.

Reviewed by Cursor Bugbot for commit 64354ca. Bugbot is set up for automated code reviews on this repo. Configure here.

Add integration tests exercising RediSearch stemming and tokenization
for languages other than English. The LANGUAGE / LANGUAGE_FIELD options
already had argument-encoding tests, but no test covered the actual
search behavior against a live server.

Covers:
- language-specific stemming (German, French, Spanish, Greek, Indonesian)
- query-time LANGUAGE option
- Chinese tokenization via the friso tokenizer
- per-document LANGUAGE_FIELD routing

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nkaradzhov
nkaradzhov requested a review from PavelPashov July 14, 2026 11:53
@nkaradzhov
nkaradzhov marked this pull request as ready for review July 14, 2026 11:53
{ language: REDISEARCH_LANGUAGE.FRENCH, text: 'Les chevaux courent vite', query: 'cheval' },
{ language: REDISEARCH_LANGUAGE.SPANISH, text: 'Nosotros hablamos mucho', query: 'hablar' },
{ language: REDISEARCH_LANGUAGE.GREEK, text: 'Οι άνθρωποι περπατούν', query: 'άνθρωπος' },
// Indonesian stemmer reduces "membaca" to the root "baca" (since 8.9.0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be since 8.10.0?


testUtils.testWithClient('per-document LANGUAGE_FIELD', async client => {
await client.ft.create('idx', { content: SCHEMA_FIELD_TYPE.TEXT }, {
LANGUAGE_FIELD: '__lang'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we broaden the LANGUAGE_FIELD TypeScript type to accept plain hash field names such as __lang? It currently requires @ or $., but Redis defines LANGUAGE_FIELD as a document attribute in the FT.CREATE documentation.

…E_FIELD

FT.CREATE defines LANGUAGE_FIELD and SCORE_FIELD as document attributes,
which for hash indexes are plain field names (e.g. __lang). The previous
RediSearchProperty type required an @ or $. prefix, rejecting valid input
at compile time. Widen both options to also accept any string while
keeping autocomplete for the prefixed forms.

Also drop the incorrect "since 8.9.0" note on the Indonesian stemming
test case: the Indonesian stemmer has been available since the
libstemmer 2.0 upgrade in RediSearch 2.0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nkaradzhov
nkaradzhov merged commit 53b7b29 into redis:master Jul 21, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants