This is the documentation of version 1.0.0-rc.0. 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(`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

    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: 0 // 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)
    • 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, 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 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

    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 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.

    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 total number of results that match the query, regardless of pagination limits.

    A total is not guaranteed, so guard it rather than assume a number. Use it to size a progress indicator, such as a page count of Math.ceil(totalResults / limit), but 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`