Hello Victoria.G
Thank you for reaching out to Microsoft Support!!
Pagination Behavior:
- The
from
andsize
parameters control pagination, but for large datasets, the API may not always return results in a predictable order. - Instead of relying solely on
from
andsize
, Microsoft recommends using the@odata.nextLink
property for pagination
Best Practices for Pagination:
- Use
@odata.nextLink
to fetch the next set of results dynamically. - Avoid manually incrementing
from
as it may not work consistently for large datasets
Reference link: https://learn.microsoft.com/en-us/graph/paging?tabs=http
Handling Duplicate Results
- Using
trimDuplicates
:- The
trimDuplicates
property is supported for SharePoint files, but it may not always remove all duplicates. - If duplicates persist, consider filtering them out programmatically by tracking unique file IDs.
- The
- Sorting Issues:
- Sorting within the query may not always work as expected for large datasets.
- Try sorting results client-side after retrieval.
Reference link: https://learn.microsoft.com/en-us/answers/questions/590157/whats-the-best-way-to-paginate-large-data-sets-usi
Recommended Approach
- Modify Your Request:
- Instead of relying on
from
andsize
, use@odata.nextLink
for pagination. - Ensure
trimDuplicates
is set totrue
, but also implement a client-side check for unique file IDs.
- Instead of relying on
- Check API Limits:
- Microsoft Graph has limits on the number of results returned per request. If you're hitting these limits, consider breaking queries into smaller chunks
Reference link: https://learn.microsoft.com/en-us/graph/api/resources/search-api-overview?view=graph-rest-1.0
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.