This is the documentation of version 0.62.0. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Type Alias FuzzySearchParams

    FuzzySearchParams: CommonSearchParams<GetObject, FuzzySearchResponseAPI> & CommonGeocodeAndFuzzySearchParams & {
        filters?: SearchFilters;
        maxFuzzyLevel?: number;
        minFuzzyLevel?: number;
    }

    Parameters for fuzzy search queries.

    Fuzzy search finds places and addresses using partial or misspelled text queries. It's designed to handle typos, abbreviations, and incomplete input gracefully.

    Type Declaration

    • Optionalfilters?: SearchFilters

      What may come back: the country and the POI-attribute restrictions together.

    • OptionalmaxFuzzyLevel?: number

      Maximum fuzziness level to be used.

      Controls the upper limit of tolerance for character differences. Higher values allow more variations but may include irrelevant results.

      The search will try increasingly fuzzy matching up to this level if no results are found at lower levels.

      2
      

      1

      4

      // Allow very fuzzy matching
      maxFuzzyLevel: 4

      // Strict matching only
      maxFuzzyLevel: 1
    • OptionalminFuzzyLevel?: number

      Minimum fuzziness level to be used.

      Controls how tolerant the search is to character differences. Lower values require closer matches to the query text.

      Fuzziness levels correspond to Levenshtein edit distance:

      • Level 1: Allows 1 character difference
      • Level 2: Allows 2 character differences
      • Level 3: Allows 3 character differences
      • Level 4: Allows 4 character differences

      Higher minimum levels make the search more lenient but may return less relevant results.

      1
      

      1

      4

      minFuzzyLevel: 2  // Require at least moderate similarity
      

    Pass these to discoverPlaces, which selects the request variant from the params it is given: a route property dispatches to along-route search, a geometries property to geometry search, and neither to fuzzy search.

    Key Features:

    • Tolerates typos and spelling mistakes
    • Handles partial queries and abbreviations
    • Searches both addresses and POIs
    • Configurable fuzziness levels for precision control
    • Ranked results by relevance

    Use Cases:

    • Search box implementations
    • User-entered free-form text searches
    • Recovery from autocomplete failures
    • Broad exploratory searches
    // Basic fuzzy search
    const params: FuzzySearchParams = {
    query: 'pizz', // Will find "pizza" restaurants
    geoBias: { position: [4.9041, 52.3676] }
    };

    // Fuzzy search with custom fuzziness
    const customParams: FuzzySearchParams = {
    query: 'restaurnt', // Misspelled "restaurant"
    minFuzzyLevel: 1,
    maxFuzzyLevel: 3,
    limit: 10
    };