Forum Discussion
MattCasey
Apr 08, 2019Copper Contributor
Graph API Drive search returns results containing all items in the drive
I'm using v1.0 API /search to find files within our drive using an app-only token using requests similar to;
drives/{driveid}/root/search(q='test')
Since 2019-04-03T18:36Z these requests are getting responses that appear to contain the entire drive full of DriveItems, files, folders, images or whatever with no relation to the search term and with an endless series of @odata.nextLink to the next page of useless results.
The same erroneous responses can been seen when making the same requests using the Graph Explorer logged in as an individual user rather than via an app-only token.
This looks to be a bug with the indexing engine.
A simple example of a good request prior to the problem starting.
GET : drives/[[REDACTED]]/root/search(q='testfile.txt') //HEADERS Content-Type = application/json; charset=utf-8 Authorization = REDACTED //BODY { "$select":"id,name,file" } //END RESPONSE 200 : 483ms //HEADERS Cache-Control = private request-id = a4140979-8c86-41f8-b197-a1b02feb74bf Status_Code = 200 Http_Version = HTTP/1.1 Explanation = OK Strict-Transport-Security = max-age=31536000 Connection = close Transfer-Encoding = chunked Date = Wed, 03 Apr 2019 16:44:13 GMT Content-Type = application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8 Vary = Accept-Encoding OData-Version = 4.0 x-ms-ags-diagnostic = {"ServerInfo":{"DataCenter":"UK South","Slice":"SliceC","Ring":"4","ScaleUnit":"000","RoleInstance":"AGSFE_IN_1","ADSiteName":"UKS"}} client-request-id = a4140979-8c86-41f8-b197-a1b02feb74bf Duration = 411.1817 //BODY { "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)", "value":[ { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"testfile.txt", "file":{ "mimeType":"application/octet-stream" } } ] } //END
And here's a sample of what the same request returns now. As you can see the results are nonsense
GET : drives/[[REDACTED]]/root/search(q='testfile.txt') //HEADERS Content-Type = application/json; charset=utf-8 Authorization = REDACTED //BODY { "$select":"id,name,file" } //END RESPONSE 200 : 671ms //HEADERS Cache-Control = private request-id = 96015ad0-3a5b-46aa-80f4-f6d6d2c903ea Status_Code = 200 Http_Version = HTTP/1.1 Explanation = OK Strict-Transport-Security = max-age=31536000 Connection = close Transfer-Encoding = chunked Date = Thu, 04 Apr 2019 08:30:11 GMT Content-Type = application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8 Vary = Accept-Encoding OData-Version = 4.0 x-ms-ags-diagnostic = {"ServerInfo":{"DataCenter":"UK South","Slice":"SliceC","Ring":"5","ScaleUnit":"002","RoleInstance":"AGSFE_IN_1","ADSiteName":"UKS"}} client-request-id = 96015ad0-3a5b-46aa-80f4-f6d6d2c903ea Duration = 631.8379 //BODY { "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)", "@odata.nextLink":"https://graph.microsoft.com/v1.0/drives/[[REDACTED]]/root/search(q='testfile.txt')?$select=id%2cname%2cfile&$skiptoken=[[REDACTED]]", "value":[ { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Other" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Sample file" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Business Contacts" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Training" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"testfolders" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"DD" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Club" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Calendar 2019.pdf", "file":{ "mimeType":"application/pdf" } }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Quick Start Guide.pdf", "file":{ "mimeType":"application/pdf" } }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Onboarding.pdf", "file":{ "mimeType":"application/pdf" } }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Offices" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Office 1" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Data" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Sprints" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Meeting Minutes" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Reports" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"IT" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"General Documentation" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Marketing" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Video demos" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Training" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Others" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Scripts" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"testfolder" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Emma" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Offices" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Offices" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Update September 2018.pdf", "file":{ "mimeType":"application/pdf" } }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Office 2" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Office 3" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Office 4" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Office 5" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Office 6" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Meeting Minutes.pdf", "file":{ "mimeType":"application/pdf" } }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Release Notes for Users" }, { "@odata.type":"#microsoft.graph.driveItem", "id":"[[REDACTED]]", "name":"Presentation" } And so on ... ] } //END
- Atul_VekariyaCopper Contributor
MattCasey
I am facing the same issue. Did you get any solutions?- MattCaseyCopper Contributor
Atul_Vekariya Hi. No proper fix so far but I did find out that you can search the entire drive still if you omit the /root part of the endpoint.
See this issue I opened in Github for more info.- Atul_VekariyaCopper Contributor
MattCasey
Yes, you're right, I tried without /root it works for me.