Find your content:

Search form

You are here

Apex SOSL Paging Implementations

 
Share

How might one implement SOSL paging, i.e. get the next 200 results, in Apex?


Attribution to: mjgallag

Possible Suggestion/Solution #1

These probably aren't the answers your looking for, but unless someone else has some clever ideas...

The current answer in the Force.com Discussion Boards : Pagination for SOSL query is:

"No, it's not possible to query more than 200 records in a SOSL query."

From SOSL Syntax

Syntax: LIMIT n

Description: Optional. Specifies the maximum number of rows returned in the text query, up to 200. If unspecified, the default is 200, the largest number of rows that can be returned.

IdeaExchange: Lift 200 record limit in SOSL


Update from Summer 2013 (API v28.0) Release Notes:

Increased Limit for SOSL Query Results
SOSL now supports up to 2000 results for each query instead of the previous limit of 200 results per query.

Increased Query Size Limit
The maximum size for a SOSL query has been increased to 20,000 characters.


Attribution to: Daniel Ballinger

Possible Suggestion/Solution #2

Use a WHERE (range) with an ORDER BY on the same column, and increase the WHERE on each page. General idea:

FIND {test}
RETURNING Account (id WHERE CreatedDate >= [last page's max createddate])
ORDER BY CreatedDate

Then you get the next 200 records, and the next paging click increments your search range criteria. It's not perfect but is a general pattern for getting around querying limits.

I somewhat agree with Lacey's reference to Atwood when it comes to building easy-to-use web software esp for B2C, but IMO there are plenty of valid use cases in business software for paging through 200+ records based on search/filter criteria.


Attribution to: jkraybill
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/894

My Block Status

My Block Content