Your retriever finds a useful passage. Then canonicalUrl + "#" + anchor sends the reader to a heading that the passage may never have belonged to.
The link looks precise. That's the annoying part.
Lab note 085: can we build section-aware retrieval from fullText and sections alone? Those fields provide article text and a heading outline, but neither connects headings to ranges in the body.
Why matching a heading can lie
The tempting repair is to search the body for each heading title, then slice between matches.
That quietly assumes a heading phrase can't appear earlier in ordinary prose. Your ingestion job has just acquired a literary opinion.
Example synthetic text makes the ambiguity visible without fetching an article:
heading_phrase = "History" synthetic_text = ( "Example: History is mentioned in this opening paragraph.\n\n" "History\n" "The section account starts here." )
naive_start = synthetic_text . find ( heading_phrase ) known_start = synthetic_text .β¦