When SharePoint 2010 came out, there was one thing that many people wanted that was no longer there out of the box: a Site Directory. I’ll be honest with you. I never much liked the Site Directory in the earlier versions of SharePoint. I felt it was clunky and it wasn’t permissions trimmed, it was based on a links list, so everyone saw everything and would click on those links and then get mad when they couldn’t get to it. For that reason, I rarely used it. I usually just recommended that people bookmark their sites so they could find what they needed quickly.
Since there was no Site Directory in SharePoint 2010, there were several solutions that people began using to keep a list of sites. One of my personal favorites was my friend Laura Rogers’ “Web Part: Sites that I have Access To.” I have used and recommended this for many of my customers and friends in the past few years as a great way to create a site directory that also only shows the user what they have the ability to access. It’s based on the Search Core Results Web Part and uses a fixed query for the sites and webs and therefore is permissions trimmed, which is awesome!
Not too long ago, I was building out a SharePoint 2013 environment and decided since I might have a lot of different site collections I’d implement the same basic solution on my main page. I dropped a web part on my page, the Search Results Web Part (slight name change) and opened up the web part edit pane and clicked “Change Query” to configure the web part. I saw pretty much what I expected, things are slightly different in 2013, but it was pretty easy to figure out. I selected to have the query text be contentclass:STS_Site contentclass:STS_Web. I clicked Test Query and saw pretty much what I expected. I knew the sites and site collections that I had already created in my farm. Cool beans. And since I was logged in as myself and I make myself the Site Collection Administrator for all my sites, I would see everything.
The problem started when I clicked “OK.” What I saw in the actual results did not match the preview or what I knew I should see on my page. The results were limited to only showing six of my eight sites. I thought, “Hmm. OK, why is it not showing me all the sites? is it paging or limited in some way?” I went through every tab for refiners and everything, and there was nothing being limited in any way. I wasn’t sure why this was happening, I wasn’t worried about the format, just the results at this point.
After scratching my head a moment, I decided to jump into my search center itself. I did searches based on the actual titles of the sites, and everything was searchable and showing me results, so I entered the same search query in search as I did in the web part. Guess what! I got the same results, only part of my sites were showing in the search center.
I remembered that we now had a new web part in SharePoint 2013, the Content Search Web Part. This web part took the Content Query Web Part (CQWP) and backed it with search so that you could easily roll up content not just within a site collection, but across web applications and even your entire farm. Very cool, right? So I decided I’d see if it would work for my purpose. I dropped the web part on the page and opened the web part panel and clicked “Change Query.” There were a few adjustments to make to this web part. By default it does not query across all web apps and site collections. I configured the settings for the web part as shown below, again using the same query.
Once I clicked out of the additional filters, it showed me a preview of my search results. It was exactly what I was looking for, again, but I wasn’t sure what was going to happen when I applied everything to my page. Now, by default, the Content Search Web Part only shows 3 items in the results, so I went ahead and changed this to a number I knew I had less results than (15 I think was what I set it to) and I also changed the display (under the Item menu) to two lines so that I could see it well on my page. After that I clicked apply and held my breath to see what was going to happen. Lo and behold, ALL of my results showed up as expected!
Now I was really confused. I knew that all of my search results should be the same in all locations. I was using the exact same search query with the exact same account. I involved a few really great resources to help me research, and after setting the logs to verbose for search we found that the queryevaluation is the issue. I do not yet know what is causing it to have an issue from the search results web part or center, but I do know that I have tried this on all versions up through August 2013 CU with the same results.
So, if you want to use Laura’s idea for creating a Site Directory and you want to make sure all of the sites are included, you should use the Content Search Web Part. As for styling this and making it pretty, I’m quite certain there are tricks to that. If I see that there’s a patch that repairs this, or learn more, I will be sure and post an update.