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

    Type Alias SearchSummary

    The metadata summary of a search API response.

    It describes how the search engine processed the query, the result counts, and the cursor that continues the search through further pages.

    This summary is included in responses from:

    const results = await discoverPlaces({
    query: 'pizza',
    geoBias: { position: [4.9, 52.3] }
    });

    const summary = results.properties;
    console.log(`Showing ${summary?.numResults} results`);
    console.log(`Query type: ${summary?.queryType}`); // 'NEARBY'
    console.log(`Search took ${summary?.queryTime}ms`);
    type SearchSummary = {
        fuzzyLevel?: number;
        geoBias?: Position;
        nextCursor?: string;
        numResults: number;
        query: string;
        queryTime: number;
        queryType: SummaryQueryType;
        totalResults?: number;
    }
    Index
    fuzzyLevel?: number

    The maximum fuzzy matching level used to find results.

    It shows how much the search relaxed exact matching. Higher values mean more tolerance for typos and variations.

    Fuzzy levels (typically 1-4):

    • 1: Single character variation (typo, insertion, deletion)
    • 2: Two character variations
    • 3: Three character variations
    • 4: Four character variations

    It is low when exact or near-exact matching finds the results, and increases to find matches when the query has typos.

    Where match strictness is not reported, the field is absent rather than 0. Read a missing value as "not reported", not as an exact match.

    // Query: "amstrdam" (typo)
    fuzzyLevel: 2 // Needed 2-character correction to match "amsterdam"

    // Query: "amsterdam" (correct)
    fuzzyLevel: 1 // Exact match, no fuzzy matching needed
    geoBias?: Position

    The geographic position used to bias search results, as [longitude, latitude].

    If present, results were prioritised by proximity to this location.

    This reflects the position from:

    • The geoBias.position parameter (explicit position bias)
    • The geoBias.boundingBox parameter (area center, if applicable)

    Results closer to this position are ranked higher.

    // Search biased toward Amsterdam
    geoBias: [4.9041, 52.3676] // [longitude, latitude]

    // Query: "Main Street" will prioritize Main Streets near Amsterdam
    nextCursor?: string

    The opaque cursor that continues this search, to pass back as the request's cursor.

    See CommonGeocodeAndFuzzySearchParams.cursor. Only fuzzy search and geocoding page this way.

    If it is absent, pagination has ended. Either the next page would start at totalResults, this page came back empty, or the next page would start past result 1900, the furthest the backend serves. Fuzzy search's totalResults is at most 100 and can be lower at a larger limit, so its pagination ends there.

    numResults: number

    The number of results in this response.

    This is the actual count of features in the results array, which may be less than totalResults due to pagination limits. Unlike totalResults, it is always present, as the length of the array you were given.

    The limit parameter of the search request controls it.

    // If limit=10 and more results exist
    numResults: 10 // Only 10 results in this response
    query: string

    The search query as interpreted and processed by the search engine.

    It may differ from the original input due to:

    • Normalization (case, spacing, diacritics)
    • Spelling corrections
    • Query expansion
    • Stop word removal
    // User input: "pizzza restaurant"
    query: "pizza restaurant" // Corrected spelling
    queryTime: number

    The time the search engine spent processing and returning results, in milliseconds.

    It does not include network latency.

    queryTime: 42  // Search took 42ms to execute
    
    queryType: SummaryQueryType

    The search type, which tells whether results are location-biased (NEARBY) or general (NON_NEAR).

    totalResults?: number

    The number of results the search API reports for the query.

    It is not guaranteed, so guard it rather than assume a number. For geocoding, it counts matches beyond the page returned. Fuzzy and geometry search report at most 100, the most one search returns, and fuzzy search's number can drop as limit grows. Along-route search reports the page's own length. So don't show it as a total except for geocoding.

    Don't drive pagination with it either. nextCursor decides whether a further page exists.

    // geocode({ query: 'Main Street' })
    totalResults: 58090 // Matches counted, this page included
    numResults: 10 // Showing the first 10

    // Fetch more by passing `nextCursor` back as `cursor`