Graph API - can $seach and $top parameters be used together?

Frances 1 Reputation point
2021-04-13T08:49:39.543+00:00

I want to get top 3 users whose displayName contains 'q'.

query:
https://graph.microsoft.com/v1.0/users?$search="displayName:q"&$top=5&$select=displayName

But the result is not what I expected. It gets the top 3 items but doesn't execute the search query.
87269-image.png

Can $seach and $top parameters be used together? Is any other alternative way I can get the correct result?

Thanks

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

1 answer

Sort by: Most helpful
  1. Diana Wanjuhi 1,376 Reputation points
    2021-04-15T09:08:15.633+00:00

    Hello @Frances to my knowledge, there isn't currently a way to fetch users by checking whether the display name contains a certain letter. I also looked into using the $filter query parameter with the contains operator, but from the filter documentation this operator is currently not supported on graph resources.

    From the $search operator documentation, searches on people occur on both the displayName and emailAddress properties of the person resource. The results here will try and match on the values passed to the query.

    You could change your query to use the: people API which will try and give the best match.

    Please let me know whether this helps,

    Diana.

    0 comments No comments