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

    Type Alias SearchSummary

    Metadata summary for search API responses.

    Provides information about the search query execution, result counts, and the cursor that continues the search. This metadata helps understand how the search was processed and page through results.

    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(`Found ${summary?.totalResults ?? 'an unknown number of'} total results`);
    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

    Maximum fuzzy matching level used to find results.

    Indicates how much the search relaxed exact matching to find results. 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

    If results are found with exact or near-exact matching, this will be low. If the query has typos, this increases to find matches.

    Optional — where match strictness is not reported the field is absent rather than 0, so read a missing value as "not reported" rather than as an exact match.

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

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

    Geographic position used to bias search results.

    When present, indicates that results were prioritized based on proximity to this location. Format: [longitude, latitude]

    This reflects the position from:

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

    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: pass it back as the request's cursor, see CommonGeocodeAndFuzzySearchParams.cursor. Only fuzzy search and geocoding page this way.

    Absent means pagination has ended: the result set is exhausted, this page came back empty, or the next page would start past result 1900, the furthest the backend serves.

    numResults: number

    Number of results included 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 this is always present — it is the length of the array you were given.

    Controlled by the limit parameter in the search request.

    // If limit=10 and totalResults=50
    numResults: 10 // Only 10 results in this response
    totalResults: 50 // 50 total matches exist
    query: string

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

    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

    Query processing time in milliseconds.

    Time spent by the search engine to process and return results. Does not include network latency.

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

    Classification of the search type.

    Indicates whether results are location-biased (NEARBY) or general (NON_NEAR).

    totalResults?: number

    Total number of matching results found by the search.

    The complete count of all results that match the query, regardless of pagination limits.

    Optional — a total is not guaranteed, so guard it rather than assuming a number. Use it to size a progress indicator, such as a page count of Math.ceil(totalResults / limit), not to drive pagination: nextCursor decides whether a further page exists.

    totalResults: 50  // 50 total matches found
    numResults: 10 // Showing first 10

    // Fetch the rest by passing `nextCursor` back as `cursor`