Home

SharePoint Search REST API returns inconsistent Total Rows Count

%3CLINGO-SUB%20id%3D%22lingo-sub-879464%22%20slang%3D%22en-US%22%3ESharePoint%20Search%20REST%20API%20returns%20inconsistent%20Total%20Rows%20Count%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-879464%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Everyone%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20a%20building%20a%20custom%20web%20part%20with%20pagination%20feature.%20To%20implement%20feature%20we%20are%20getting%20Total%20rows%20count%20and%20showing%20possible%20number%20of%20pages.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhile%20implementing%20we%20are%20running%20queries%20using%20startRow%20and%20rowLimit%20query%20string%20parameters.%20When%20I%20change%20the%20startRow%20TotalRows%20attribute%20returning%20different%20number%20for%20the%20same%20queryText.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExample%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftenant.sharepoint.com%2F_api%2Fsearch%2Fquery%3Fquerytext%3D'test'%26amp%3Bstartrow%3D0%26amp%3BrowLimit%3D10%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ftenant.sharepoint.com%2F_api%2Fsearch%2Fquery%3Fquerytext%3D'test'%26amp%3Bstartrow%3D0%26amp%3BrowLimit%3D10%3C%2FA%3E%20returns%20%3CSTRONG%3ETotalRows%20125%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftenant.sharepoint.com%2F_api%2Fsearch%2Fquery%3Fquerytext%3D'test'%26amp%3Bstartrow%3D10%26amp%3BrowLimit%3D10%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ftenant.sharepoint.com%2F_api%2Fsearch%2Fquery%3Fquerytext%3D'test'%26amp%3Bstartrow%3D10%26amp%3BrowLimit%3D10%3C%2FA%3E%20returns%20%3CSTRONG%3ETotalRows%20112%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20TotalRowsInclusingDuplicates%20property%20returns%20consistent%20value.%20However%2C%20If%20I%20try%20to%20use%20start%20row%20above%20the%20TotalRows%20count%20then%20getting%200%20results.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20wondering%20why%20Rows%20Count%20is%20varies%20by%20StartRow.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20anyone%20facing%20same%20issue%20or%20any%20suggestions%20is%20very%20much%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3EVenkat%20Konjeti%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-879464%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1022400%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Search%20REST%20API%20returns%20inconsistent%20Total%20Rows%20Count%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1022400%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F94170%22%20target%3D%22_blank%22%3E%40Venkat%20Konjeti%3C%2FA%3E%26nbsp%3BHi%2C%20this%20is%20by%20design%20when%20you%20use%20duplicate%20trimming%2C%20as%20trimming%20the%20full%20result%20set%20is%20time%20consuming%2C%20so%20it%20will%20re-calculate%20as%20you%20are%20paging.%3C%2FP%3E%3CP%3EMy%20personal%20opinion%20is%20that%20you%20should%20turn%20off%20duplicate%20trimming%20as%20it's%20too%20coarse%20(%3CA%20href%3D%22https%3A%2F%2Fwww.techmikael.com%2F2013%2F12%2Fduplicate-trimming-in-sharepoint-2013.html%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.techmikael.com%2F2013%2F12%2Fduplicate-trimming-in-sharepoint-2013.html%3C%2FA%3E).%20Append%26nbsp%3B%26amp%3Btrimduplicates%3Dfalse%20and%20you%20should%20be%20good%20to%20go.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20a%20side%20not%2C%20if%20you%20get%20very%20many%20results%2C%20then%20the%20exact%20count%20might%20also%20be%20off%2C%20due%20to%20the%20query%20returning%20within%20a%20timeout%20interval.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Venkat Konjeti
New 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
Highlighted

@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.