> ## Documentation Index
> Fetch the complete documentation index at: https://product-discovery.developer.voyado.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Autocorrect and facet selection

> Keep search results accurate when a visitor applies a facet filter after Elevate has autocorrected their query.

When a visitor performs a search containing a misspelling, Elevate's autocorrection feature may return results for the corrected term. The autocorrection feature is exposed via the [search page](/elevate/docs/api/storefront/v3/queries/search-page) endpoint or method. However, if the visitor then applies a facet filter, the autocorrection is no longer applied automatically. To ensure consistent and relevant results, the `q` parameter in subsequent requests must use the corrected phrase returned from the initial search.

<Warning>
  If the next request still uses the misspelled term in the `q` parameter, autocorrection will not be applied. This may yield no hits, or yield hits based on the misspelled term, which can confuse site visitors. Use the corrected phrase from the initial search response in all follow-up queries with facets.
</Warning>

## Implementation

### Sending the initial search request with a misspelling

The visitor searches with a misspelled term, for example "jakcet", and the following query is sent to Elevate:

`/storefront/v3/queries/search-page?customerKey=TEST&sessionKey=TEST&touchpoint=DESKTOP&locale=sv-SE&market=SE&q=jakcet`

### Capturing the corrected phrase

The response will include search results based on the autocorrected term, along with the corrected phrase itself (for example, "jacket"). Below is a snippet of Elevate's response:

```json icon="code" theme={null}
{
   "q": "jakcet",
   "autoCorrect": {
     "q": "jacket",
     "originalTotalHits": 0
   }
}
```

### Sending the corrected phrase when applying facets

When the visitor applies a facet (for example, `color=BLUE`), send the corrected phrase in the `q` parameter instead of the original misspelling:

`/storefront/v3/queries/search-page?customerKey=TEST&sessionKey=TEST&touchpoint=DESKTOP&locale=sv-SE&market=SE&q=jacket&f.color=BLUE`

## Summary

To maintain search accuracy after a misspelled query followed by a facet selection:

1. Accept the misspelled input in the first request.
2. Present a visual cue that the phrase has been autocorrected, such as text that says "Your search for jakcet did not match any products, corrected to jacket", and present the search results based on the autocorrected phrase. If the original phrase has `originalTotalHits > 0`, you can provide a link back to the original misspelled phrase using the parameter `origin=UNDO_AUTO_CORRECT`.
3. If a visitor selects a facet, use the corrected phrase in all follow-up requests with facets.
