What's the limitation about Graph API search?

Henry Jia 21 Reputation points
2022-06-10T07:31:24.14+00:00

What we want is get a list of files with specified extension in a given folder or its sub folders.

And the search API is used in pattern
https://graph.microsoft.com/v1.0/me/$drive$/items/$itemid$/search(q='$ext$')?$filter=endsWith(name, '$ext$')
Where
$drive$ can be drive (for ones own) or drives/%driveId% (for shared item)
$itemid$ is the drive item id of the given folder
$ext$ is file extension such as xlsx

But for different account (personal, business) / share folder we get kinds of different unexpected results as following:

  1. 501 (error code: notSupported, filter related) (business account)
    210129-notsupported.png If remove the $filter, it works with 200 success response code. But the filter works for personal account:
    210048-workedfilter.png
  2. Search is not always work for shared folder, some works but others not (no match), even they all shared by same account. Search with no matched items for bundle shared. (a personal to personal share) The following picture gives three shared folders from same person:
    210049-shareditems.png
    You can see they has same value for parentReference.driveId. The 1st one is a bundle.
    Search works for the last one (id: 9F06E2BEF31BA398!110) but no match for other two:
    Worked item (https://graph.microsoft.com/v1.0/me/drives/9f06e2bef31ba398/items/9f06e2bef31ba398!110/search(q='xlsx')?$filter=endsWith(name, 'xlsx')):
    210050-searchshareok.png No matched items:
    1. Normal
      210192-share138ng.png
      Replace search(...) with children, you can find there has matched files:
      210191-filesinshare138.png
    2. Bundle
      210100-searchsharebundleng.png
      Replace search(...) with children, you can find there has matched files:
      210109-filesinbundleshare.png

So we want to know is any limitation about the usage, or another way / API can help to ensure we get the expected result.

Thanks in advance,

Henry

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

2 answers

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,696 Reputation points Microsoft Vendor
    2022-06-14T15:07:40.107+00:00

    Hi @Henry Jia ,

    As per documentation driveitem-search GET /me/drive/root/search(q='{search-term}') supports only $expand, $select, $skipToken, $top, and $orderby OData query parameters to customize the response.

    Usage $filter is not currently supported on this API.

    Alternatively, consider use of POST /search/query and Use filters in search queries.

    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".

    0 comments No comments

  2. Henry Jia 21 Reputation points
    2022-06-17T01:22:37.453+00:00

    Hi @SrinivasaRaoDarnaMSFT-7657
    Thank you for your answer about the usage of $filter, we can remove it and do filter to the response manually.

    How about the difference that related with search in shared folder, it not always works?

    0 comments No comments