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: 4333

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?

Hi,

What do you mean by

"For this to work the web part must be set to render Async Client Side in the browser in the web part settings"

I do not see any such render async client side setting for content search we part.

Kindly help me with detailed steps how I can increase maximum number of items for a content search web part.

Thanks,

I ran into this same issue and needed to display about 200 results.  Matt Stark's client-side solution appeared to work for us, but it requires being authenticated to the site.  I published a blog post here that shows how to increase the limit to 500 using a server-side approach that works for an anonymous sites:  http://www.scottewing.net/Blog/Post/2/Getting-Around-the-Content-Se....  I believe it might be possible to go higher than that, as one blogger wrote that it requires changing the search service's MaxRowLimit property (default is 500).

Hi, for my project i'm using this infinite loading webpart - http://www.eliostruyf.com/create-a-load-more-results-link-button-fo... ..

But for one list (new employees) we wanted to show all 150 items (more or less) .. after we tried examples on this forum, we found new solution.

So, we changed behavior of infinite loading web-part, there is ShowMoreResults.js that loads items on click:

 // When clicked on the show more link, the new set of results needs to be retrieved
 $('#'+controlId+'showmore').click(function () {
  // Load the next set of results
  ctx.ClientControl.page(lastPage.startItem);
  return false;  
 });

And we changed that to fire on load:

 /* auto load until all items shown*/
 ctx.ClientControl.page(lastPage.startItem);
 

Now on page load we have all 155 items and page loading time is normal.

But.. There's one issue with this fix/hack - when you refresh page you will get only items in last set of items. For example: web-part is showing 50 items, when you click 'Show more' it loads next 50, and  next time it loads last 5 items. This 5 items will be shown on page refresh (f5).

One of solution could be to disable refersh click with this:
function disableF5(e) {
    if ((e.which || e.keyCode) == 116) {    e.preventDefault();    }
};

As we have employee filters on this list.. I decide to prevent page refresh and reset filter options. It's very similar experience to page refresh.

Hope this will help you.

Marin

Hello Marin Buric, Thanks for suggesting the link. It helped me resolve my requirement as well.

For the issue related to refresh, instead of disabling refresh, I retrieve all the items by paging to the first item from the search. A small extract for the same is below;

var IsRefresh = sessionStorage.IsRefresh;

if (IsRefresh != null && IsRefresh != "") {
    //cookie exists then you refreshed this page(F5, reload button or right click and reload)
    sessionStorage.IsRefresh = "";
    ctx.ClientControl.page(1);
}
else {
    if(lastPage.startItem<0){
        visibleElm.remove();hiddenElm.remove();
        sessionStorage.IsRefresh = "True";
    }
    else{
        ctx.ClientControl.page(lastPage.startItem);
    }
}

The code checks the Session storage to retrieve a check flag for complete Page Load or Page Refresh. The accordingly paging is done using

ctx.ClientControl.page(page number);

wherein page number here is the first Page.

RSS

© 2014   Created by Mark Jones.   Powered by

Badges  |  Report an Issue  |  Terms of Service

Live Support