The Type-Ahead stage takes partly typed text, such as 412 n ma, and writes the addresses from your own datasets that best match it, best first.
An address API from API Builder already answers type-ahead as it is. Use the stage when the answer needs steps of your own around it: a flow that answers an API request can take the text, suggest addresses, keep only those in the caller's district, and return them.
Set it up
- From the Addressing category, add Type-Ahead to the flow.
- Under Dictionary, choose the country and the address datasets, and map their fields, exactly as for the Geocoder.
- Under Input and Output, choose the Typed Text field: the one that holds what the person has typed so far.
- Set how many Suggestions to return for each text, from 1 to 10.
- Choose what to Write: One Row per Suggestion, which suits an API answer because the rows are the list, or One Row per Text, with the suggestions as a list.
- Under Try a Text, type a text and choose Suggest to see what the stage suggests and which dataset each suggestion comes from. It is answered by the same rule the flow uses, so the same text gives the same suggestions when the flow runs.
Datasets are asked in the order listed, exactly as for the Geocoder: the next dataset suggests only when the ones before it suggest nothing, so the same address is never suggested twice.
In an API
When the flow answers an API request, its dictionary is prepared when the API is built, with the layers the flow reads, not on every call. The API answers from the dictionary as of that build: choose Refresh data on the API's page after the datasets change.
What the stage produces
- Suggestions: each suggestion with its rank, its text, its record ID, the dataset it came from and its location.
- No Suggestions: texts with nothing to suggest, with the reason: no text, text shorter than two characters, or nothing matched.