Home
Content Management API⁡𝅶‍‍𝅺⁡‍𝅴⁡𝅴𝅹‍‍⁢𝅵‍‍⁣⁣‌⁡⁣𝅺⁣⁢⁣𝅸⁠⁢‍‍‍𝅷‍‍𝅳⁡‍⁠‍‍⁢𝅵‍‍𝅳⁡⁣⁡⁣⁡​⁡⁢⁢𝅵‍𝅺‍𝅺⁢𝅸⁡⁢‍𝅹⁣‌⁡⁣𝅺⁢𝅸⁡⁢‍𝅹⁢𝅺𝅸‍𝅺⁠⁣𝅴⁡⁣𝅺⁡‍‍𝅺𝅴⁡⁣⁠𝅸⁠𝅺⁡⁣⁡𝅴⁡​⁠⁡⁢‍𝅺⁢𝅳⁢‌⁢​⁢𝅴⁢‍⁢⁠‍𝅺𝅴⁡⁣⁠𝅸⁡⁢‍𝅺⁢⁢⁢𝅴⁢𝅳⁢⁢⁢‌⁢⁡⁢𝅳⁢‌‍‍⁡𝅸
Main resources
Upload-related
Site Search
Environments
UI
Workflows
Async jobs
Roles & permissions
Webhooks
Hosting & CI integrations
Subscription
Enterprise
    Show examples in:
    Search for results

    Returns a list of search results matching your query.

    By default, it returns 20 results. You can paginate the results using limit and offset parameters. In any case, a maximum number of 100 results is returned.

    Query parameters

    filter  object  Required

    Attributes to filter search results

    page  object  Optional

    Attributes to manage results pagination

    Returns

    Returns an array of search_result resource objects.

    Examples

    Example code:
    import { buildClient } from '@datocms/cma-client-node';
    async function run() {
    const client = buildClient({ apiToken: '<YOUR_API_TOKEN>' });
    // this only returns the first page of results:
    const searchResults = await client.searchResults.list({
    page: {
    offset: 200,
    limit: 20
    },
    filter: {
    fuzzy: true,
    query: 'florence apartments',
    build_trigger_id: '44',
    locale: 'it'
    }
    });
    searchResults.forEach((searchResult) => {
    console.log(searchResult);
    });
    // this iterates over every page of results:
    for await (const searchResult of client.searchResults.listPagedIterator(
    {
    filter: {
    fuzzy: true,
    query: 'florence apartments',
    build_trigger_id: '44',
    locale: 'it'
    }
    }
    )) {
    console.log(searchResult);
    }
    }
    run();
    Returned output:
    {
    id: '12adNIIB8rFJF1DoTgCk',
    title: 'Florence Apartments for Rent | Long Term Student Accommodation Rentals',
    body_excerpt: 'Finding a place to live while planning to study abroad in Florence can be both exciting and challenging. With this in mind, Housing in Florence assists you in finding conveniently-located housing based...',
    url: 'http://www.website.com/some-page',
    score: 11.3,
    highlight: {
    title: [
    '[h]Florence[/h] Apartments for Rent | Long Term Student Accommodation Rentals'
    ],
    body: [
    'All our student accommodation and apartments in [h]Florence[/h] are fully'
    ]
    }
    }