Atomic Angular — Doc interne

Did You Mean

Turn a result's spelling correction into the right message — the engine corrected the query, expanded it, or only suggests a correction — and let the user switch between the two spellings.

When the engine corrects a misspelled query, three different things could actually have happened to the search: the corrected term fully replaced the original, both spellings were searched together, or nothing was searched yet and the engine only proposes a correction. <did-you-mean> reads which one from the result and renders the matching message, with links to switch spellings.

Concept — applied changes

Since engine 11.14, a corrected result reports didYouMean.text.appliedChanges — one entry per corrected term, each naming the actual action the engine took (correction, expansion, or suggestion). Before 11.14 that field does not exist, and the component falls back to inferring the action from spellingCorrectionMode.

Minimal example

Rendered next to a result list
results.component.ts
import { Component, signal } from "@angular/core";
import { DidYouMeanComponent } from "@sinequa/atomic-angular";
import type { Result } from "@sinequa/atomic";

@Component({
  selector: "results-component",
  imports: [DidYouMeanComponent],
  template: `
    @if (result(); as r) {
      <did-you-mean [result]="r" />
    }
  `,
})
export class ResultsComponent {
  protected readonly result = signal<Result | undefined>(undefined);
}

How it works

Which message renders depends entirely on the resolved action — a computed the component derives from the result, never set directly:

no yes yes, all same action yes, actions differ no Correct Smart other result().didYouMean.text corrected present? Nothing renders appliedChanges reported (engine ≥ 11.14)? Use that action suggestion (safest default) spellingCorrectionMode correction expansion suggestion

A mixed result — some terms corrected, others expanded — deliberately falls back to suggestion: it is the only one of the three messages that does not assert a specific search behavior that may not actually have happened for every term.

The three messages

ActionMeaningMessage
correctionThe original term was replacedShowing results for Catalon. Search instead for katalon
expansionBoth spellings were searched togetherShowing results for katalon and Catalon
suggestionOnly the original was searchedDid you mean Catalon?

Options

Prop

Type

selectCorrected() and selectOriginal() are the two methods every message's links call — both patch QueryParamsStore with spellingCorrectionMode: "dymonly" and navigate with the chosen text, so the engine does not re-correct the choice the user just made.

Pitfalls

What's next

On this page