I create custom search for SharePoint search. if i search it wit page size 10 and page index (0 or 1 or 2) total result count will be 55 when actual result 40, else if page size 10 and page index 4 total result count will be 50 and no rows returned else if page size 10 and page index 3 total result count will be 40, else if page size 100 and page index 0 total result count will be 40.
My Code:
private static DataTable ExecuteSearchQuery(SPWeb web, int pageNumber, int pageSize, ref long totalRecords)
{
FullTextSqlQuery query = new FullTextSqlQuery(web.Site);
query.StartRow = pageSize * (pageNumber - 1);
query.RowLimit = pageSize;
query.TrimDuplicates = true;
query.ResultTypes = ResultType.RelevantResults;
query.QueryText = @"SELECT ID, Title, Modified ,URL FROM Scope() WHERE (CONTAINS(Url, '/lists/Comments') AND FREETEXT(Title,'*any*'))";
ResultTableCollection results = query.Execute();
DataTable searchResults = results[ResultType.RelevantResults].Table;
totalRecords = query.QueryInfo.TotalResults;
return searchResults;
}