在使用 SharePoint Search REST Api 时,我遇到了以下问题,如果我使用不同rowlimit
的值,totalrows
属性会改变它的值。例如,对于这样的请求:
http://my-site/_api/search/query?querytext='test'&rowlimit=10
我得到以下回复:
<d:RowCount m:type="Edm.Int32">10</d:RowCount>
<d:Table m:type="SP.SimpleDataTable"></d:Table>
<d:TotalRows m:type="Edm.Int32">22</d:TotalRows>
另一方面,通过这个请求,http://my-site/_api/search/query?querytext='test'&rowlimit=5
我得到了这个:
<d:RowCount m:type="Edm.Int32">5</d:RowCount>
<d:Table m:type="SP.SimpleDataTable"></d:Table>
<d:TotalRows m:type="Edm.Int32">28</d:TotalRows>
我已经使用 CSOM Api 进行了检查,它返回与 REST 相同的值:
using (var clientContext = new ClientContext(_url))
{
var keywordQuery = new KeywordQuery(clientContext)
{
QueryText = "test",
RowLimit = 10 //and then 5
};
var searchExecutor = new SearchExecutor(clientContext);
var results = searchExecutor.ExecuteQuery(keywordQuery);
clientContext.ExecuteQuery();
Console.WriteLine("total rows: {0}", results.Value[0].TotalRows); // 22 and then 28
}
为什么会这样,我该如何解决这个问题?