Autocomplete and fuzzy search

VERSION 0.2.1455
PUBLIC PREVIEW

Fuzzy search is the default, generic search service. It can handle vague and imprecise inputs and supply results for:

  • Areas on the map (countries, states, cities).
  • Specific addresses with a street name and number (2501 Soquel Drive, Kalverstraat 23).
  • Address ranges on streets where address points are interpolated along the length of the street.
  • Streets.
  • Junctions, places where two streets intersect.
  • Point of interest (Restaurant, Sports Center).

Fuzzy search requests are built using the FuzzySearchQuery class. To create FuzzySearchQuery you have to use FuzzySearchQueryBuilder. The only required parameter for fuzzy search is the query string parameter. The other parameters are optional.

let builder = FuzzySearchQueryBuilder(query: "Pizza")

To get the best experience, consider:

More information about best practices is described at Best Practices. A detailed description of Fuzzy Search and its parameters can be found in the Search API Fuzzy Search documentation.

Once you have a FuzzySearchQuery object, provide it to the TomTomOnlineSearchService.

1let query = builder.build()
2searchService.fuzzySearch(query: query) { searchResponse, error in
3 if let searchResponse = searchResponse {
4 // handle success
5 } else if let error = error {
6 // handle error
7 }
8 // Your code goes here.
9}

Autocomplete

Autocomplete helps users make more effective searches. It recognizes entities inside an input query and offers them as query terms. This improves the accuracy of the search results.

Autocomplete requests are built using the AutocompleteQuery class that can be made using AutocompleteQueryBuilder. The required parameters are the query and the language in which autocomplete results should be returned. You can also provide optional parameters to perform a more accurate search, following similar recommendations as for fuzzy search. Also, see more information in the Search API Autocomplete documentation.

let builder = AutocompleteQueryBuilder(query: "Piz", forLanguage: "en-GB")

Once you have an AutocompleteQuery object, provide it to the TomTomOnlineSearchService.

1let query = builder.build()
2searchService.autocomplete(query: query) { autocompleteResponse, error in
3 if let autocompleteResponse = autocompleteResponse {
4 // handle success
5 } else if let error = error {
6 // handle error
7 }
8 // Your code goes here.
9}