I have a List in a SharePoint Online site collection which has exceeded 5000 items. I have indexed the columns that are needed in the REST API filter query during list creation itself.
Below is the Rest API query I use to fetch the data from the list.
https://sptenant.sharepoint.com/sites/spfxqaw44/_api/web/lists/getByTitle('Announcements')/items?$top=4999
&$filter=(Expires ge '2022-12-06T18:30:00.000Z') and (RecordDate le '2022-12-06T18:30:00.000Z') and IsActive eq 1 and WorkflowCompleted eq 1
&$select=Id,Title,Expires,ShortDescription,Created,RecordDate,Attachments,LangTrans&$expand=AttachmentFiles&$orderby=RecordDate desc
The above query gave me an error as threshold limit exceeded. So I have created a simple list and made a API call as below,
https://sptenant.sharepoint.com/sites/testsite/_api/web/lists/getByTitle('LoadTestList')/items?$filter=Title ne 'Load Test'&$top=4999
Generally the return data count should be 4999 but I am able to get only 4970 items as response data. Also this response count is unpredictable, for some other lists I got response count less than 4000.
Any idea on this inconsistent behavior?
$filter=Title ne 'Load Test'&$top=4999
?