LIMIT n

LIMIT is an optional clause that can be added to a SOSL query to specify the maximum number of rows that are returned in the text query, which can be up to 2,000 results. If unspecified, the default is the maximum 2,000 results.

The default of 2,000 results is the largest number of rows that can be returned for API version 28.0 and later. Previous versions return up to 200 results.

The LIMIT clause can’t increase the maximum number of records returned. See SOSL Limits on Search Results.

You can set limits on individual objects or on an entire query.

When you set a limit on the entire query, results are evenly distributed among the objects returned. For example, let’s say you set an overall query limit of 20 and don’t define any limits on individual objects. If 19 of the results are accounts and 35 are contacts, then only 10 accounts and 10 contacts are returned.

FIND {test} RETURNING Account(id), Contact LIMIT 20

Setting individual object limits allows you to prevent results from a single object using up the maximum query limit before other objects are returned. For example, if you issue this query, at most 20 account records can be returned, and the remaining number of records can be contacts.

FIND {test} RETURNING Account(id LIMIT 20), Contact LIMIT 100

If you specify a limit of 0, no records are returned for that object.