Our SDKs are designed to simplify paging, so you do not need to worry about the underlying details. You can simply iterate through a search response and the SDK will automatically fetch the next page(s) when it needs to (lazily).
The SDKs will even add a default sort by GUID to ensure stable results across pages, even when you do not provide any sorting criteria yourself.
Automatic paging
123456
client.assets.select()// .pageSize(50)// .stream()// .limit(100)// .filter(a->!(ainstanceofILineageProcess))// .forEach(a->log.info("Do something with each result: {}",a));//
client.assets.select()// .pageSize(50)// .stream()// .limit(100)// .filter{it!isILineageProcess}// .forEach{log.info{"Do something with each result: $it"}}//
Use an SDK
The SDKs manage making multiple requests and parsing results to make subsequent requests in the most efficient way possible. You will need to make many different API requests if you want to do the same directly via the raw REST APIs.
For curious minds, though, you can page through search results using a combination of the following properties1:
Property
Description
Example
from
Indicates the starting point for the results.
0
size
Indicates how many results to include per response (page). As a general rule of thumb we would recommend a size from 20-100, making 50 a common starting point.
50
track_total_hits
Includes an accurate number of total results, if set to true. With its default value on the raw REST APIs (false) the maximum number of results you will see in the approximateCount field in the response is 10000. (Again, the SDKs set this to true by default to avoid this confusion.)
true
Constraints with this approach
To have the most consistent results you can when paging, you must always use some sorting criteria and include at least one sorting criteria as a tie-breaker. (You must also keep that criteria the same for every page.)
Furthermore, as you get to larger from sizes (more than ~10,000) Elastic will begin to use significantly more resources to process your paging. To reduce this impact, if you need to page through many results you should implement your own timestamp-based offset mechanism so that the from size is kept consistently low.
(Again, the SDKs do both of these for you automatically.)
IndexSearchResponseresponse=index.search(client);// longtotalResults=response.getApproximateCount();// for(Assetresult:response){// // Do something with each result of the search...}response.forEach(a->log.info("Found asset: {}",a.getGuid()));// response.stream()// .filter(a->!(ainstanceofILineageProcess))// .limit(100)// .forEach(a->log.info("Found asset: {}",a.getGuid()))//
Annotated sort options, as you would define them in the Python SDK
client=AtlanClient()response=client.asset.search(index)# total_results=response.count# forresultinresponse:# # Do something with each result of the search...
Annotated sort options, as you would define them in the Java SDK
valresponse=index.search(client)// valtotalResults=response.approximateCount// for(resultinresponse){// // Do something with each result of the search...}response.forEach{log.info{"Found asset: ${it.guid}"}}// response.stream()// .filter{it!isILineageProcess}// .limit(100)// .forEach{log.info{"Found asset: ${it.guid}"}}//
If you're familiar with Elasticsearch there are an alternative paging options using search_after and point-in-time (PIT) state preservation. (There also used to be scrolling, but this is no longer recommended by Elasticsearch.) We do not currently expose the search_after or PIT approaches through Atlan's search. However, you should still be able to page beyond the first 10,000 results using the approach outlined above. ↩