You Get More Results in the Query Builder for a Web Part Than When the Web Part is Rendered on the Page in SharePoint 2013

I’ve had this issue happen to me a while back and then I saw two other people have the same problem in the last couple of weeks so I decided to do a quick post on this. The scenario usually manifests itself something like this: you are working on some kind of custom search application – like doing a query based a custom managed property or something like that. You edit the search web part properties and open up the query builder. When you run your query in there you see all of your search results being returned. However, when you save the web part changes and load the page, you don’t see all of the search results; you get a smaller number of results returned.

One of my initial efforts at fixing this was to change the trim duplicates property in the web part to false, even though I knew I did not have any real duplicates in my search results (they were all site collections, something I would not have thought we would even do a duplication check on). That did not fix the problem anyways, but one of the folks here suggested that using that property in the web part settings may not be sufficient to actually resolve the problem.

His suggestion was to export the web part and save it locally. If you open it up in an editor like Notepad, look for property called DataProviderJSON, and you will see a sub-property in there called TrimDuplicates. By default it is true, so change it to false and then import the .webpart back into a site collection and add it to the page. I was happily surprised to find that this did in fact fix this problem for me, and I started getting back a full set of results. I burned a lot of hours though trying to get this working “as expected” out of the box, so hopefully this post will save you some time.