How to get more than 50 item search results in a SharePoint 2013 display template

Today I had to modify an existing SharePoint 2013 Content By Search Web Part that used a custom display template to show more than 50 search results without paging!

I came across a blogpost from Scott Ewing describing the different options. Basically you have 3 different options in an on-premise environment:

  • Attempt a client-side approach to override the 50 result limit: We tried this approach but it didn’t work in an anonymous scenario.
  • Try to override the behavior of the ContentBySearchWebPart on the server-side, possibly using reflection if necessary: We didn’t like the fact to override this behavior. Also when a user changes the webpart properties you will end up with an ugly error message.
  • Figure out how to use a jQuery infinite scrolling approach with SharePoint search results: Yes, this is the way to go, but can we do it without the scrolling part? Can we immediately show more than 50 results? Of course … read on …

The infinite retrieving of items was also described in a blogpost by Elio Struyf, only it seamed not to work when refreshing the page. So I combined the approach found in a reply by Anvil DSouza. Another small issue with the sample from Elio Struyf seamed to be that it didn’t work when search results were less than 50 items. Also that little bug is solved by the below code.

Enough chitchat, let’s get to the code. A lot of inline comments are added to explain all steps.


4 thoughts on “How to get more than 50 item search results in a SharePoint 2013 display template

  1. Hello,

    I tried to implement your script but there is an error saying that your ‘lastPage’ is undefined (OnPostRender: ) and indeed, I’m working on it 🙂

  2. Okey, problem resolved – you need to add “var lastPage = pagingInfo[pagingInfo.length – 1];”
    Enjoy :))


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.