Skip to content

Fixes #22011: Make search accent-insensitive - #33600

Merged
harshach merged 6 commits into
mainfrom
fix/22011-accent-insensitive-search
Sep 19, 2026
Merged

harshach merged 6 commits into
mainfrom
fix/22011-accent-insensitive-search

Conversation

@harshach

@harshach harshach commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #22011

A Portuguese speaker whose table is named Manutenção types Manutencao and gets zero results. The mirror case fails too — the person searching does not know whether whoever named the asset used accents, so Ambulatório must also reach a table named Ambulatorio.

om_analyzer tokenized Operatório to operatório, so the indexed term and the query term never unified. The n-gram band could not rescue it either: every 3-gram spanning the accent differs from the query's. No asciifolding existed anywhere in the en/jp/zh analysis chains — ru had it in two of its five, which is why Russian deployments never saw this.

I added asciifolding to every analysis chain that lowercases, across all 250 mapping files.

Type of change:

  • Improvement

High-level design:

Approach. asciifolding is inserted directly after lowercase in every analyzer and normalizer that lowercases:

om_analyzer:           [word_delimiter_filter, lowercase, asciifolding, om_stemmer, om_plural_stemmer]
om_ngram:              [lowercase, asciifolding]
om_compound_analyzer:  [compound_word_delimiter_graph, lowercase, asciifolding, flatten_graph]
om_substring:          [lowercase, asciifolding]
lowercase_normalizer:  [lowercase, asciifolding]

The position is load-bearing, and is asserted by a test rather than left to reviewer memory:

  • folding is a case-sensitive mapping, so it must run after lowercase or the uppercase forms are left alone;
  • it must run before the stemmers, or they never see the folded token.

Why the keyword normalizer is included. The exactName ranking stage queries name.keyword / displayName.keyword / fullyQualifiedName. Without folding there, an accented name is found but never reaches the identity band, so a row that merely starts with the query takes the top result away from the asset the query actually names. This is the Operatório vs Operatorio_Backup case in the tests.

Scope. All four languages. asciifolding is a built-in filter and was already on this repo's built-in allowlist (IndexAnalyzerMappingTest.everyAnalyzerFilterIsDefinedOrBuiltIn), so no filter declarations were needed. The change also closes pre-existing gaps in ru, whose om_ngram and om_compound_analyzer never folded. om_analyzer_jp (kuromoji) is untouched — it has no lowercase stage, and the jp mappings carry a latin om_analyzer alongside it that does fold.

Alternative considered. A second, dedicated normalizer applied only to name.keyword / displayName.keyword / fullyQualifiedName, leaving lowercase_normalizer alone. Rejected for consistency with the ru mappings, which have shipped wholesale folding for a while, and because accent-insensitive filtering is desirable on the same grounds as accent-insensitive search. See "Behaviour change to be aware of" below — happy to switch if reviewers prefer the narrower blast radius.

Rollout / backward compatibility. No migration script is needed. IndexMappingVersionTracker hashes each mapping file and reindexes entities whose hash changed, so existing deployments pick this up automatically on upgrade. Until that reindex completes, accented documents keep their old tokens — the same rolling behaviour as any other mapping change.

Behaviour change to be aware of. lowercase_normalizer is also on facet fields (tags.tagFQN, domains.displayName.keyword, ownerDisplayName). Terms-aggregation bucket keys come from doc values, so a tag named Não Público will now render as nao publico in Explore facets. These keys are already lowercased today, so this is an incremental change of the same kind, but it is user-visible. The flip side is that filtering becomes accent-insensitive too.

Tests:

Use cases covered

  • A user searching Manutencao finds the table named Manutenção (cedilla + tilde).
  • A user searching Ambulatório_Geral finds the table named Ambulatorio_Geral (accented query, plain-ASCII asset).
  • A user searching cirurgico finds a table whose description reads "bloco cirúrgico".
  • A user searching Operatorio gets the table named Operatório ranked first, above Operatorio_Backup, which merely starts with the query as a literal token.
  • Every shipped mapping in en/jp/ru/zh still creates and still serves the Explore / RBAC / Data Quality queries that depend on it.

Unit tests

  • Added IndexAnalyzerMappingTest.everyLowercasingChainAlsoFoldsAccents — asserts across all four languages that every analyzer and normalizer which lowercases also folds, directly after lowercase. The analysis block is duplicated into each of the 250 mapping files and a new entity is added by copying an existing one, so this is the drift guard for the whole set.
  • Files updated: openmetadata-service/src/test/java/org/openmetadata/service/search/IndexAnalyzerMappingTest.java
  • RED before the fix: 852 chains lowercase without folding (en 244, jp 239, ru 131, zh 235, root 3). GREEN after: 0.
  • Coverage %: not applicable — this PR changes no production Java. The change is entirely in openmetadata-spec index-mapping resources; the two Java files touched are tests.
  • Regression run on the surrounding search unit tests — 313 passed: IndexAnalyzerMappingTest, SearchIndexSettingsTest, SearchSourceBuilderFactoryTest, DataProductIndexMappingTest, SearchIndexFactoryTest, SearchRankingHelperTest, SearchIndexReindexFieldsParityTest.

Backend integration tests

  • Added openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/AccentInsensitiveSearchIT.java (4 tests). Nothing is mocked: tables are created through the real API and searched through /v1/search/query, so the shipped searchSettings.json, the real index mappings and a live search engine are all in the loop.

  • Verified RED → GREEN on both engines:

    Elasticsearch 9.3.0 OpenSearch 3.4.0
    before the fix 4/4 fail (3 return 0 hits, 1 ranks wrong) 4/4 fail
    after the fix 4/4 pass 4/4 pass
  • No regressions in the neighbouring search ITs (Elasticsearch): SearchResourceIT 69, SearchConsumerFieldBehaviorIT 20, IndexTemplateIT 10, SearchRankingRelevanceIT 5 — all green. SearchConsumerFieldBehaviorIT is the meaningful one here: it creates the real index for en/jp/ru/zh and runs the actual Explore/RBAC/Data-Quality queries against each, so it proves the folded mappings are valid and behaviourally intact in every language.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Verification here was the automated end-to-end suite above rather than a click-through, since the change is in the analysis chain and the ITs drive the real API and real engine. Reproducible:

  1. mvn -o install -pl openmetadata-spec -DskipTests
  2. Elasticsearch: mvn -o verify -pl openmetadata-integration-tests -Dit.test=AccentInsensitiveSearchIT
  3. OpenSearch: mvn -o verify -pl openmetadata-integration-tests -Ppostgres-opensearch -Dit.test=AccentInsensitiveSearchIT
  4. Revert openmetadata-spec/src/main/resources/elasticsearch/, reinstall, re-run either — all 4 fail, three of them returning zero hits.

Root cause was also confirmed directly against a live node via _analyze: pre-fix, om_analyzer on Operatório emits [operatório]; post-fix it emits [operatorio].

UI screen recording / screenshots:

Not applicable — no UI changes.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. — no JSON Schema change; these are index mappings, and IndexMappingVersionTracker reindexes on hash change, so no migration script is required.
  • For UI changes: N/A, no UI changes.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added tests around the new logic.
  • For connector/ingestion changes: N/A.

Note for reviewers

SearchRankingRelevanceIT.singularQueryFindsThePluralTable fails on OpenSearch when it shares a lane with the new IT. I confirmed this is not caused by this change: with and without the fix it produces byte-identical scores, 23.880476 vs 23.877653. BM25 term statistics are shard-wide rather than filtered, so any test adding rows to table_search_index perturbs them, and that assertion decides a strict ordering on a 0.012% margin while its siblings in the same class use a 1.25x band ratio. Pre-existing fragility, but it will surface in CI if both land in the same lane — happy to give that assertion the same band-ratio treatment in this PR or a follow-up.

🤖 Generated with Claude Code

RetriggerConfidence Score: 4/5

The search-analyzer changes are well tested, but the unresolved collapse of accent-distinct keyword facet values remains blocking.

Findings

  1. P1 Accent-distinct facets collapse ▶
Summary

The PR makes search accent-insensitive by adding asciifolding immediately after lowercase throughout the Elasticsearch/OpenSearch analyzers and normalizers for all shipped languages.

  • Adds an invariant test covering every lowercasing analysis chain.
  • Adds live-engine integration coverage for accented and unaccented names, descriptions, and exact-match ranking.
  • Updates 250 mapping resources so their hashes trigger the existing reindexing mechanism.
  • The earlier concern about applying folding to shared keyword normalizers remains unresolved: accent-distinct facet and filter values still collapse onto the same normalized term.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Indexed or queried text] --> B[Tokenizer]
    B --> C[lowercase]
    C --> D[asciifolding]
    D --> E{Analysis chain}
    E --> F[Stemming]
    E --> G[N-gram generation]
    E --> H[Keyword normalization]
    F --> I[Accent-insensitive search terms]
    G --> I
    H --> J[Exact-match, filter, and facet terms]
Loading

Reviews (6) · Last reviewed commit: "Merge branch 'main' into fix/22011-accen..."

A Portuguese speaker whose table is named "Manutenção" types "Manutencao"
and gets nothing back. The mirror case fails too: the person searching does
not know whether whoever named the asset used accents, so "Ambulatório" must
also reach a table named "Ambulatorio".

om_analyzer tokenized "Operatório" to "operatório", so the indexed term and
the query term never unified. The n-gram band could not rescue it either --
every 3-gram spanning the accent differs from the query's. No asciifolding
existed anywhere in the en/jp/zh analysis chains; ru had it in two of its
five, which is why Russian deployments never saw this.

Add asciifolding directly after lowercase in every chain that lowercases,
across all 250 mapping files. The position is load-bearing: folding is a
case-sensitive mapping, so it has to run after lowercase, and before the
stemmers so they see the folded token. The keyword normalizer is included
because the exact-match ranking stage queries name.keyword -- without it an
accented name is found but never reaches the identity band, and a row that
merely starts with the query takes the top result away from it.

This also closes the gaps in ru, whose om_ngram and om_compound_analyzer
never folded.

Existing deployments pick this up on their own: IndexMappingVersionTracker
hashes each mapping file, so the changed mappings trigger a reindex on
upgrade.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@harshach
harshach requested a review from a team as a code owner September 18, 2026 17:10
"filter": [
"lowercase"
"lowercase",
"asciifolding"

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.

P1 Accent-distinct facets collapse

Adding asciifolding to lowercase_normalizer makes distinct facet values that differ only by accents share one keyword term. For example, coexisting Manutenção and Manutencao domains now produce the same aggregation bucket. Selecting that bucket issues a term filter that matches both domains, so users cannot distinguish or filter them independently. The same issue affects fields such as tags.tagFQN that use this normalizer.

@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Sep 18, 2026
Comment thread docs/webhook-ssrf-advisory-response.md Resolved
This reverts commit 68496f6.

The advisory response document is unrelated to the accent-insensitive
search change and was committed to this branch by mistake.

Co-Authored-By: Claude Opus 5 <[email protected]>
@gitar-bot

gitar-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🔴 High risk

Adds accent-insensitive search by inserting asciifolding directly after lowercase in all analyzer and normalizer chains across 250 mapping files for English, Japanese, Russian, and Chinese. Includes comprehensive unit tests asserting folding order and coverage across all languages, and end-to-end integration tests covering accented names, descriptions, reverse matching, and exact-match ranking on both Elasticsearch and OpenSearch. No issues found.

Review coverage

Rules No rules evaluated

Functional validation Not enabled · Set up

Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make search accent-insensitive

2 participants