The arithmetic you observed is a classic unsigned 32-bit overflow: values above 4,294,967,296 bytes (2^32, which is exactly 4 GiB) wrap around by that constant, so a 5 GiB file is reported as roughly 1 GiB and a 6 GiB file as roughly 2 GiB. This strongly suggests that the Microsoft Search index is storing the Size field as a 32-bit integer rather than a 64-bit integer, so the indexed value truncates whenever a file exceeds 4 GiB and the search filter Size>=4294967296 never matches those rows. To confirm, compare the search result for an affected file against a direct GET request to /drives/{driveId}/items/{itemId}/?$select=size; the driveItem endpoint returns the full 64-bit size while the search index returns the wrapped value, which isolates the bug to the Search indexing or response path. As a workaround, do not filter on the indexed Size property for large files; instead retrieve candidates and validate the actual size using the driveItem endpoint, and consider reporting the 4 GiB boundary to Microsoft Support with client-request-id and request-id headers so the Search team can fix the managed property.
Graph API search/query not recording file size over 4gb (over 2^32 bytes) correctly
Hi,
I'm having this issue where I'm trying to search for files using the graph api's search/query with something like this:
POST
{
"requests": [{
"entityTypes": ["driveItem"],
"query": { "queryString": "Size>=4294967296" },
"from": 0,
"size": 25,
"fields": ["name", "size", "fileTotalSize"],
"sortProperties": [{ "name": "Size", "isDescending": true }]
}]
}
But the files I see in my tenant that are over 4gb are not returning back. The fileTotalSize is properly returning back the file's sizes, though some of them returns additional size due to versions on the files, but the item's size is not correctly returning for files over 4gb.
But when I lower my threshold to 1GB and re-run the query, I see that my 5gb and 6gb files are being returned, but it looks like the size that its returning is its actual size minus 2^32gb. (ie. 5gb file is returning as 1gb, 6gb file is returning as 2gb)
Can you help me understand why this is happening? is there a bug with the search/query index that's not properly storing/retrieving the size value?
Windows for home | Windows 10 | Files, folders, and storage
2 answers
Sort by: Newest
-
AI answer
2026-11-06T17:47:35.8633333+00:00 Compare each affected Search hit with a direct
GET driveItemrequest; if the direct response contains the correct 64-bit size while/search/queryreturns the value modulo2^32, report it as a Microsoft Search service defect and do not use the indexedSizeproperty for filtering files above 4 GiB.Why the values wrap
Your examples follow an exact unsigned 32-bit wraparound:
-
5 GiB = 5,368,709,120bytes → reported as1,073,741,824bytes -
6 GiB = 6,442,450,944bytes → reported as2,147,483,648bytes - Difference:
4,294,967,296bytes, exactly2^32
That is strong evidence that the Search representation of
Sizeis being truncated or converted through a 32-bit numeric value. Microsoft’s documented Search limitations do not list a 4-GiB file-size boundary ^1^, and SharePoint’s published search limits likewise do not document such a limit for theSizemanaged property ^2^.This establishes a likely overflow defect, but not whether it occurs while indexing, evaluating KQL, serializing the Search response, or parsing it in your client.
Isolate Search from driveItem metadata
Take the
driveIdand item ID from an affected Search hit, then request the item directly:GET https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{item-id}?$select=id,name,size Authorization: Bearer {token} client-request-id: {new-guid}The direct endpoint retrieves the item’s metadata and returns a
driveItem; it requires at least delegatedFiles.Read, orFiles.Read.Allfor application access ^3^.sizeis a documented property of that resource ^4^.Compare the raw JSON, before SDK or application deserialization:
- Run your existing
/search/queryrequest and save the raw response. - Run the direct request above for the same item.
- Compare:
- Search
size - Search
fileTotalSize - Direct
driveItem.size
- Search
- Repeat with files just below and above
4,294,967,296bytes.
Interpret the result as follows:
- Direct size correct; Search size wrapped: the problem is in the Microsoft Search/index response path.
- Both raw responses correct; application value wrapped: change the client model to a 64-bit integer, such as C#
long, Javalong, or JavaScriptnumber/BigIntas appropriate. - Both raw responses wrapped: provide both requests to Microsoft Support because the issue is not isolated to Search.
Microsoft Search officially supports returning OneDrive and SharePoint files as
driveItemresults and supports KQL property restrictions only where the managed property is valid and queryable ^5^. Therefore, changing>=syntax or sorting direction is unlikely to correct an indexed value that has already wrapped.Workaround
There is no documented query expression that reconstructs the original value after a
2^32truncation. Until Microsoft fixes or confirms the behavior:- Do not rely on
Size>=4294967296or Search sorting bySize. - Retrieve candidate items and validate each one with
GET /drives/{drive-id}/items/{item-id}?$select=id,name,size. - If every file must be evaluated, enumerate the drive hierarchy and follow pagination, then filter on the direct
driveItem.sizevalues. Search alone cannot reliably identify all affected files because a file between 4 and 5 GiB can wrap to a value below 1 GiB.
Report the defect
Send a unique
client-request-idwith each reproduction and retain the responserequest-idandDateheaders. Microsoft specifically requests these values for diagnosing Graph failures ^6^.Include:
- Tenant cloud/region, without posting tenant identifiers publicly.
- Exact UTC timestamp.
- Raw Search and direct-driveItem requests and responses.
-
client-request-id, responserequest-id, andDate. - Expected and actual byte values.
- A minimal set of test files immediately below and above
2^32. - Confirmation that the same behavior occurs outside your SDK, such as with Graph Explorer or another raw HTTP client.
References
- Use the Microsoft Search API to query data
- Search limits for SharePoint
- Get driveItem - Microsoft Graph v1.0 | Microsoft Learn
- driveItem resource type - Microsoft Graph v1.0 | Microsoft Learn
- Use the Microsoft Search API to search OneDrive and SharePoint content
- How to debug Microsoft Graph API calls
AI-generated content may be incorrect. Read our transparency notes for more information. -