SharePoint Search REST API query not returning all results

Have you ever faced a scenario where you have built search customization using Rest API with SPFx or custom display template in SharePoint 2013 etc which did not return all search results. I was facing this today while trying to get data based on a content type, it was returning only few results.

The reason is because Search API by default removes duplicates as documented by Microsoft. Items that are identical or nearly identical are removed from the result set.

https://docs.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-search-rest-api-overview#trimduplicates

Set the property trimduplicates to false on the Search API as below if there is a need

https://domainname/sites/sitename/_api/search/query?querytext=’contenttype:”the name of the content type”‘&trimduplicates=false&rowlimit=500&selectproperties=’Title’&sortlist=’LastModifiedTime:descending’

Hope it helps someone.

One thought on “SharePoint Search REST API query not returning all results

  1. Thank you very much – this default option had an extreme impact on me, as instead of 150+ results I was getting only 5 (searching for all Document libraries in site collection).

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s