How can I control my search so that only search in single level of folder or nested level of folder.

Nakul Chaudhary 0 Reputation points

I want to implement search such that I can do search on First level of folders and files rather that searching on nested folders.

Deafult behaviour is it search under each nested folder for specified path.

My current code is

SearchRequest request = new SearchRequest();

request.Query = new SearchQuery { QueryString = searchTerm };

request.EntityTypes = new List<EntityType?> { EntityType.DriveItem };

request.Size = limitReturns;

QueryPostRequestBody qprb = new QueryPostRequestBody();

qprb.Requests = new List<SearchRequest> { request };

var responce = graphServiceClient.Search.Query.PostAsQueryPostResponseAsync(qprb).Result;

Please suggest.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,485 questions
0 comments No comments
{count} votes