SharePoint Search REST API returns inconsistent Total Rows Count

Copper Contributor

Hello Everyone,

 

We are a building a custom web part with pagination feature. To implement feature we are getting Total rows count and showing possible number of pages.

 

While implementing we are running queries using startRow and rowLimit query string parameters. When I change the startRow TotalRows attribute returning different number for the same queryText.

 

Example:

https://tenant.sharepoint.com/_api/search/query?querytext='test'&startrow=0&rowLimit=10 returns TotalRows 125

 

https://tenant.sharepoint.com/_api/search/query?querytext='test'&startrow=10&rowLimit=10 returns TotalRows 112

 

But TotalRowsInclusingDuplicates property returns consistent value. However, If I try to use start row above the TotalRows count then getting 0 results.

 

I am wondering why Rows Count is varies by StartRow.

 

Is anyone facing same issue or any suggestions is very much appreciated.

 

Thanks

Venkat Konjeti

 

1 Reply

@Venkat Konjeti Hi, this is by design when you use duplicate trimming, as trimming the full result set is time consuming, so it will re-calculate as you are paging.

My personal opinion is that you should turn off duplicate trimming as it's too coarse (https://www.techmikael.com/2013/12/duplicate-trimming-in-sharepoint-2013.html). Append &trimduplicates=false and you should be good to go.

 

As a side not, if you get very many results, then the exact count might also be off, due to the query returning within a timeout interval.