why wouldn't
contains()
orendswith()
be indexed as well?
NOTE: contains()
and endswith()
are NOT indexed because they require scanning every row, making them slow. SharePoint does not support reverse or full-text indexing in Graph API, which would be needed for contains() and endswith(),
Recommended way is to use startswith()
for fast Graph API queries For more details Refer this QnA.
startswith()
is indexed because SharePoint stores data in sorted and indexed structure, allowing quick lookups without scanning the entire dataset, which makes more efficient compared to contains()
and endswith()
.
Generated the access token and used the same $filter
query with startswith()
:
GET https://graph.microsoft.com/v1.0/sites/<site-id>/lists/<list-id>/items?$filter=startswith(fields/FileLeafRef, 'query')
Reference: