Show examples in:
JavascriptHTTP
Endpoint info
Available examples
Content Management API > Search result

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

filterobject

Attributes to filter search results

querystring

Text to search

Example:"florence apartments"
fuzzyboolean

When any value is passed, it enables the fuzzy search: the Levenshtein Edit Distance is used to match more results.

search_index_idstring

The search index ID on which the search will be performed. If not provided, the first enabled search index will be used.

Example:"12345"
localestring

Restrict the search on pages in a specific locale

Example:"it"
build_trigger_idstringDeprecated

The build trigger ID or name on which the search will be performed.

Use search_index_id instead: this parameter is only supported for backward compatibility and will return an error if the build trigger has multiple search indexes associated.

Example:"44"
pageobject

Parameters to control offset-based pagination

offsetinteger

The (zero-based) offset of the first entity returned in the collection (defaults to 0)

Example:200
limitinteger

The maximum number of entities to return (defaults to 20, maximum is 100)

Returns

Returns an array of resource objects of type search_result.

Examples

GET https://site-api.datocms.com/search-results?filter[query]=florence%20apartments HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Terminal window
curl -g 'https://site-api.datocms.com/search-results?filter[query]=florence%20apartments' \
\
-H "Authorization: Bearer YOUR-API-TOKEN" \
-H "Accept: application/json" \
-H "X-Api-Version: 3"
await fetch(
"https://site-api.datocms.com/search-results?filter[query]=florence%20apartments",
{
headers: {
Authorization: "Bearer YOUR-API-TOKEN",
Accept: "application/json",
"X-Api-Version": "3",
},
},
);
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 28
{
"data": [
{
"type": "search_result",
"id": "12adNIIB8rFJF1DoTgCk",
"attributes": {
"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": {}
}
}
],
"meta": {
"total_count": 20
}
}