How to override content by search Web Part's limit of 50 results per page?

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.

Tags: 2013, SharePoint

Views: 1542

Reply to This

Replies to This Discussion

Well, why would we need more than 50 items per page, then?

Client Requirement

Okay, okay.

You may consider the following post to get it done - Customize SharePoint Search Results Paging…!!!. Yea, this been around since 2007/2010, the same story - inherit core result, override few methods and setup items per page property manually. Also, consider google "search core result web part 50 limit" - pretty much lots of info.

On the other hand, it might be nice thing to adop and educate customer as more than 50 item par page might not be a business requirement. 

Extending the web part via the API doesn't work either, I've tried it.  Trying to see if Microsoft will put a patch in to allow it to be overwritten.  Other option would be custom KQL web part.

I have the same problem, I want to create a display of all employees (approx 80 persons). I want to display that using the search web part that returns all persons with the email corresponding of the company. Everything works, but I have this limitation (50 person max) that is boring me !

What web part (or other thing) can I use to display more than 50 person ??

Thanks by advance, have a good week end !

Cédric

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>

 

Hi,

Can you provide me with the script sample to implement Infinite scrolling/paging in search result page?

RSS

© 2014   Created by Mark Jones.   Powered by

Badges  |  Report an Issue  |  Terms of Service

Live Support