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.