Repository navigation
Fixes #37345: keep glossary synonym n-gram queries under the clause limit - #37385
Conversation
…imit synonyms.ngram, added by #34052, used om_ngram to analyze the query as well as the index, so every query word became one clause per 3-20-character n-gram. Together with name.ngram and displayName.ngram, that took the composite-alias search past the glossary term shard's 1024-clause limit. SearchCountConsistencyIT has failed in main's nightly embedded search lane on every run since 11-05. The en and ru mappings now analyze synonyms.ngram queries with om_compound_analyzer. A word inside a synonym still matches the stored n-grams, at one clause per word. zh keeps its 2-3-character n-grams on both sides; they stay few, and Chinese partial matching needs them. GlossarySynonymNgramIT covers both behaviors. On the previous mapping, its 80-letter query fails with maxClauseCount.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| "ngram": { | ||
| "type": "text", | ||
| "analyzer": "om_ngram" | ||
| "analyzer": "om_ngram", | ||
| "search_analyzer": "om_compound_analyzer" | ||
| } |
There was a problem hiding this comment.
⚠️ Quality: Query-side analyzer rule for synonyms.ngram is not recorded anywhere
This PR sets a rule that keeps queries under the clause limit, but the rule exists only in the PR description. No record in docs/decisions/ mentions n-gram fields, search_analyzer or the clause limit. The repo squash-merges, so the reasoning behind the en/ru vs. zh/jp/ko split won't reach git log. A later change could set the zh/jp/ko mappings the same way as en/ru and break Chinese partial matching. Or it could switch synonyms.ngram back to n-gramming the query and bring back the 1024-clause failure caught by SearchCountConsistencyIT. This is also the latest of several PRs on the same n-gram trade-off (#34052, #33456, #22108).
The record would say: "On the glossary term index, synonyms.ngram indexes 3–20-character n-grams (om_ngram) but analyzes queries as whole words (search_analyzer: om_compound_analyzer), so each query word costs one clause instead of one per n-gram. The zh/jp/ko mappings keep n-gramming the query, because their 1–3-character grams keep the clause count low and CJK partial matching depends on it. name.ngram and displayName.ngram still n-gram the query, and a single word of about 40+ characters can still hit the clause limit through them." This comes from the description's points that the change keeps "each query word to one clause", that "the zh mapping is unchanged, since its short n-grams keep query clauses few and Chinese partial matching depends on n-gramming the query", and the out-of-scope note about name/displayName.ngram.
Add a decision record, e.g. docs/decisions/2026-11-07-glossary-synonym-ngrams-are-matched-by-whole-query-words.md, that states the rule above, and have the mapping/test cite it as ADR:2026-11-07-glossary-synonym-ngrams-are-matched-by-whole-query-words.:
# Glossary synonym n-grams are matched by whole query words
Status: Accepted
On the glossary term index, `synonyms.ngram` is indexed with `om_ngram` (3–20 chars)
and searched with `om_compound_analyzer`, so a query costs one clause per word and
stays under the 1024-clause limit. zh/jp/ko keep n-gramming the query: their 1–3 char
grams keep clause counts low and CJK partial matching needs it. `name.ngram` and
`displayName.ngram` still n-gram the query; words of ~40+ chars can exceed the limit.
Was this helpful? React with 👍 / 👎
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
Describe your changes:
Fixes #37345
Since #34052 added
synonyms.ngramto the glossary term mapping on 11-05,SearchCountConsistencyIT.compositeAliasCountsIncludeGovernanceWithTheSameMatchingRuleshas failed on every run of main's nightly embedded search lane: openmetadata-nightly runs 42332334156, 42441273737 and 42571915700. It also fails locally on every run. The glossary term shard rejects the composite-alias search:Cause.
searchSettings.jsonhas listedsynonyms.ngramas a fuzzy glossaryTerm search field since Data contracts support for tables & Multi Domain Migration #22108. Until Fixes #33456: align glossary synonym mappings #34052 the subfield didn't exist, so that clause matched nothing.om_ngram(3–20-character grams) as both the index and the search analyzer. The query text is now n-grammed too: every query word becomes one clause per n-gram, on top of whatname.ngramanddisplayName.ngramalready add.SearchEntityTypeCountsrejects the partial response.Fix. In the en and ru mappings,
synonyms.ngramkeeps indexing n-grams but analyzes the query withom_compound_analyzer. That analyzer lowercases, ASCII-folds, splits on case changes, digits and underscores, and doesn't stem.synonymsmapping #33456 asked for.om_ngrammakes 2–3-character grams, so its query clauses stay few, and Chinese partial matching depends on n-gramming the query.search_analyzercan be updated on an existing field, so the mapping update applies it in place.name.ngramanddisplayName.ngramstill n-gram the query, so a single word of roughly 40 or more characters can still reach the limit through them. That predates #34052 and is left alone here.Type of change:
High-level design:
N/A — two-line mapping change.
Tests:
Use cases covered
synonyms.ngram.synonyms.ngramstays under the 1024-clause limit. It was 1,251 n-gram clauses before.Unit tests
Backend integration tests
SearchCountConsistencyIT: 6/6 with this change. On main without it, it fails with the error above.GlossarySynonymNgramITqueriessynonyms.ngramon the glossary term index through the test-support search endpoint. It passes with this change; on main's mapping it fails on the 80-letter query withHTTP 400 … query_shard_exception: failed to create query: maxClauseCount is set to 1024, while the synonym-word check passes either way.Both ran embedded (PostgreSQL + OpenSearch):
mvn -pl openmetadata-integration-tests -am verify -P search-it -Dit.test=SearchCountConsistencyIT,GlossarySynonymNgramIT -DdatabaseType=postgres -DsearchType=opensearch -Djpw.data.mode=ingestIngestion integration tests
Playwright (UI) tests
UI screen recording:
Not applicable — no UI change.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.🤖 Generated with Claude Code