Source: https://developers.woosmap.com/products/multisearch-lib/fallback-concept/

> For clean Markdown of any page, append `.md` to the page URL.

> For a complete documentation index, see https://developers.woosmap.com/llms.txt

# Fallback Autocomplete Services



## Fallback configuration

This library implements a fallback system enabling to switch from one API to another. This
system is flexible and can be manually adjusted for each API in order to be efficient for each of your specific use
cases.

Two parameters have an impact on the fallback:

#### fallbackBreakpoint

Two possible uses for the `fallbackBreakpoint` parameter:

- `fallbackBreakpoint: false`: API can't fallback and will continue to provide a suggestion.
- `fallbackBreakpoint: 0.3 //float (between 0 and 1)`: Describes at what point does the match algorithm give up.
  A `fallbackBreakpoint` of `0.0` requires a perfect match whereas a `fallbackBreakpoint` of `1.0` would match anything.
  This means that when the suggestion score is greater than the `fallbackBreakpoint` value set, the library will stop calling the
  corresponding API and switch to the next one (depending on the API order).

A default value is defined for each API:

| API                         | parameter/provider name | default `fallbackBreakpoint` |
|-----------------------------|-------------------------|:-:---------------------------|
| Woosmap Search API (stores) | `STORE`                 | `1`                          |
| Woosmap Localities API      | `LOCALITIES`            | `0.4`                        |
| Google Places API           | `PLACES`                | `1`                          |

#### minInputLength

Autocomplete service will return an empty result and no fallback will be triggered until the user input length reaches the
`minInputLength` value.

## How is the score calculated?

The score could be considered as a [Levenshtein Distance](https://en.wikipedia.org/wiki/Levenshtein_distance) between
those two strings: the input from the user and the value (`formatted_address` or `store_name`) of a returned
autocomplete item. We use the fuzzy searching JavaScript library [Fuse.js](https://fusejs.io/) in all our MultiSearch
SDKs (Javascript, iOS and Android).

Generally speaking, fuzzy searching (formerly known as *approximate string matching*) is the technique of finding
strings that are *approximately* equal to a given pattern (rather than exactly).

Have a look at the [Fuse.js scoring explanation](https://fusejs.io/concepts/scoring-theory.html) for more details.
