SharePoint 2013 renders a maximum of 50 search results per page.
It is not possible to change this hardwired limit by configuring the web part.
If you set it to greater than 50, it throws an error.
I am told that the search control needs to be overridden or extended in Visual Studio.
I want the limit to be removed entirely. If this is not possible then set it to the maximum possible value.
However, paging still needs to work, so if I set the page size to 1000 then it will render 1000 results per page.. etc.
By virtue of the way this is implemented OOTB MS says we shouldn’t be doing this. There are better approaches using infinite scroll & paging.
However, with some razzle dazzle and a little JavaScript syrup, it is definitely possible.
Summary:
A call is made to a global $create method that creates the CSWP’s UI / executes startup search.
Reassign the global variable to a custom method $create = updateResultCountCreate.
Perform type check for both: Srch.ContentBySearch and Srch.DataProvider and update the arguments numberOfItems/resultsPerPage on both options (need to do both to make this work).
In this case we’re using 500 – 10x more than the max. maxItems = 500.
For this to work the web part must be set to render Async Client Side in the browser in the web part settings.
Script:
You may add this script to your page layout, or into a page script control or build this into a custom web part.
The following script will change ALL ContentBySearch web parts on the page to display 500 items (note, you may interrogate the b variable for more settings):
<script type=”text/javascript”>
var $ocreate = null,
maxItems = 500;
// on application initialization steal the global create variable and intercept calls to create UI widgets.
Sys.Application.add_init(function() {
$ocreate = $create;
$create = updateResultCountCreate;
});
// listen to UI widget calls for CBS & DP
function updateResultCountCreate(a,b){
var ps = Array.prototype.slice.call(arguments, 0);
if(a == Srch.ContentBySearch) b.numberOfItems = maxItems;
if(a == Srch.DataProvider) b.resultsPerPage = maxItems;
$ocreate.apply(this,ps); // apply the original $create method that we stole
}
</script>