Tuesday, July 12, 2011

New Job and Fun with Search Customization

I left the hospital and moved to a prominent PR firm about a month ago. I'm now heading up a team of developers and picking up the rest of the architecture rather quickly that will basically turn me into an architect/project manager. It's a pretty cool environment that is truly an enterprise implementation. It looks like we'll actually get to play around with a lot of the buzzwords surrounding SharePoint (ie. ECM, WCM, mobile, intra-/inter-/extra-net, multi-tenancy, etc.).

I'm hoping this experience will give me enough knowledge to start giving back to the SharePoint community by the way of presenting at SharePoint Saturdays or other conferences. I'd also like to get enough out of it to help me get the MCM certification. First, I need to do the other 4 MCTS certs, but that'll come over the next 12 to 18 months, I think. I'm a little wary of certifications when looking at job candidates because of test bank sites, but the MCM sounds like it's cheat-proof.

Now, for the technical part of this session.

I've only toyed with SharePoint Search (on 2007, no less) in the past and never very deeply. One of the requests we had was to add blog search functionality to our intranet. There's about a dozen blogs currently and I expect it to grow substantially in the next 6 months (NOTE: We're a PR firm so we do social and web 2.0 ALL the time...might as well do it internally, too).

Our blogs all derive from a tree of Content Types that derive from Post.


My plan was to create a search scope that pulled only on the lowest (highest?) common denominator CT, Company-Post. I figured since the 3 below it all inherited from it, the scope would pull them.

That is not the case.

Well, at least not the way I was doing it. What I ended up doing was adding rules for each CT as "include." Not that big of an issue, but I'll just have to remember to add new rules if additional post CTs are created.

Once I created the scope and kicked off a full crawl, I built a few more pieces.

First, a page in Search Center with an OotB Search Core Results web part configured to pull just from that scope. Also, I tweaked the XSL to remove the default link at the end of every result (I think it's ugly) and added Blog Name - Author - Publish Date - Comment Count.

I also customized the refinement panel to show the Blog Title instead of the URL. Michal Pisarek has a few blog posts on the refinement panel that got me moving (Post 1, Post 2, Post 3). Add his blog to your RSS reader of choice.

These are the 2 metadata property mappings I added (one for comment count and the other for Site/Blog Title). Cropped pictures show Property Name and Mapping from Search Service Metadata Property Mappings page:



After mapping those, it does require a crawl. I did a couple of full crawls while doing this, but that's in a test/dev environment. When I push to production, I'll wait until everything is in place.

The other piece I added was a simple search box to the post.aspx and default.aspx of each blog with a target results page of the Search Center page above and the scope set to the custom scope.

That's it! Very simple implementation. No custom code or even SharePoint Designer required! I did use Visual Studio to edit the XSL, but that's just because I have it and am comfortable with it's XML/XSL editing functionality. I'm sure there are several equally useful free tools out there as well.

One neat trick with the search results web parts. If you can't remember the XML structure of the results query, drop this into the XSL:

No comments:

Post a Comment