SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.23k stars 990 forks source link

Rest API not returning all users when searching #9585

Open Kris3D opened 3 months ago

Kris3D commented 3 months ago

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

SharePoint REST API

Developer environment

None

What browser(s) / client(s) have you tested

Additional environment details

Describe the bug / error

API search on localpeople does not return all users. Only a portion of the users present are returned when queried.

Steps to reproduce

  1. call the rest api and search for users. Not all are returned as should be expected. https://tenantname.sharepoint.com/_api/search/query?querytext='user'&sourceid='b09a7990-05ea-4af9-81ef-edfab16c4e31'

Expected behavior

Return all users when calling the search API for users.

aaclage commented 3 months ago

Dear Mr. @Kris3D

After review you post this looks to be related with query build, maybe could recommend review associated doc below: https://learn.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-search-rest-api-overview

There are multiple parameters that could help display content sample "rowlimit=30", take in consideration that search uses paging approach to display content, don't know if this could be the reason is not displaying all users

Kris3D commented 3 months ago

@aaclage

The query is not the problem. When I search for a specific user using the office Portal and through the API, I get different results. The API doesn't return all matching users. Rowlimit has nothing to do with it since the max results of my query don't exceed 5 users when testing. The SP https://mytenant-admin.sharepoint.com/_layouts/15/TenantProfileAdmin/ManageUserProfileServiceApplication.aspx gives correct results.

stevebeauge commented 2 months ago

Can you try using Search Query tool, and search your user with its exact user name ? Then, in the result pane you can see "all managed metadata" associated with the search item.

  1. Ensure you have the desired data indexed
  2. Check the configuration of the managed property: is it included in the full text index?
  3. What about if you explicitly specify the managed property as a property restriction query (mean yourproperty:user instead of user)

As a side note, be aware the user profile indexation has a very low reindexing rate; if you setup custom schema mapping, you may have to wait up to 1 week to see the result