Fallback Autocomplete Services
Fallback concept explaining when and how to switch between autocomplete providers to get the best user experience.
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. AfallbackBreakpoint
of0.0
requires a perfect match whereas afallbackBreakpoint
of1.0
would match anything. This means that when the suggestion score is greater than thefallbackBreakpoint
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 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 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 for more details.