Retrieval and RAGQuery understanding and retrieval designStaff
How can text analysis lose an exact incident ID, and how would you repair the search path?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
The source and user query both contain INC-42-B, yet keyword search yields terms about INC and B and loses 42. Explain which analyzer/mapping behavior can cause this, design exact-ID and descriptive-text fields, and test canonicalization, source-ID collisions and permission filtering through the real query API.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
A full-text query searches the terms produced by its analyzer, which may differ from the visible source string. The index analyzer may split at punctuation or discard numbers, lowercase terms, or use a different analyzer from the query path. For example, Elasticsearch's simple analyzer splits at non-letters and removes numbers. That is useful for natural words and destructive for an incident ID. A document containing the visible string is not proof that the index stored that string as one searchable term.
With the simple analyzer’s documented non-letter splitting, INC-42-B becomes inc and b. The distinct identifier INC-99-B can then produce the same terms. A scoring change cannot recover the discarded digits. An exact identifier field preserves the source-defined identity, while a separate analyzed description field supports words such as “checkout outage.” Query routing can choose the exact field when a recognizable ID is supplied and keep descriptive retrieval for broader questions.
I would run the analyzer on the document field and on the query, print the tokens, then inspect the generated query against the mapping. If the identifier has its own structured field, index a canonical keyword representation and query that field exactly, with a carefully defined case and punctuation policy. Elasticsearch's keyword analyzer preserves the whole input as one token. Keep an analyzed text field as well so a user can still search the surrounding incident description. Make exact-ID matches eligible for a dedicated retrieval path before any semantic reranker or fusion step can bury them.
Canonicalization needs discipline. INC-42-B, inc-42-b and INC 42 B may or may not be the same ID in the source system. Normalize according to the identifier contract, not a generic lowercasing rule, and verify that two distinct IDs never collapse. Test the actual query API, not just the analyzer in isolation. A filter or permission check may still remove a valid hit after exact matching.
If an interviewer says BM25 should rank the exact match highest, ask what terms BM25 actually saw. The scoring algorithm cannot recover a full identifier that the analyzer discarded. This is a different failure from a hybrid merger demoting a correct keyword hit that it did retrieve.
Inspect both indexing and query analysis. Fixing only the query analyzer cannot recreate an unsplit term that was never indexed. A mapping change may therefore require building and validating a new index generation. Compare source-ID coverage and exact lookup results before switching reads, preserving deletes and permission updates during the transition. Keep the original identifier bytes for display and provenance even if a validated canonical form is used for lookup.
A minimal fixture includes INC-42-B, INC-99-B and any case or punctuation variants the source treats as aliases. Assert that real term-level lookups select the intended canonical identity and that unauthorized objects remain absent. If aliases collide, reject or disambiguate them instead of merging records. This tests the indexed representation itself, while the hybrid-fusion question begins after an exact keyword hit was already found.
Related questions
Keep practising retrieval and rag
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux