Home | Blog | Screencasts | Projects
# Wednesday, February 24, 2010

One of the nice things about SharePoint 2010 is that the developers did not seal the classes of the common web parts, so we can now create our own web parts that derive and extent the functionality. I thought it might be fun to play with the search refiner web part that I blogged about recently, so I took the standard search refiner and plugged in the excellent tag cloud implementation from codeplex.

 

So instead of rendering the normal list of refiners with counts against them, it instead uses the count to determine the tag cloud size:

VisualTagCloudRefiner

 

 

The code for creating this is below:


public class VisualRefiner : Microsoft.Office.Server.Search.WebControls.RefinementWebPart
    {
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            var xmlDoc = this._RefinementManager.GetRefinementXml();

            var filters = xmlDoc.GetElementsByTagName("Filter");

            Dictionary tags = new Dictionary();
            foreach (XmlNode filter in filters)
            {
                var valueNode = filter.SelectSingleNode("Value");
                var countNode = filter.SelectSingleNode("Count");
                if (countNode != null && valueNode != null)
                {
                    if (!string.IsNullOrEmpty(countNode.InnerText))
                    {
                        int tagCount;

                        if (int.TryParse(countNode.InnerText, out tagCount))
                        {
                            if (!tags.ContainsKey(valueNode.InnerText))
                            {
                                tags.Add(valueNode.InnerText, tagCount);
                            }
                        }
                    }
                }
            }

	    //TODO: Make the url useable
            var tagCloud = new TagCloud(tags, 
		new TagCloudGenerationRules { Order = TagCloudOrder.Random, TagUrlFormatString = "/pages/search.aspx" });

            writer.Write(tagCloud);
            
        }
        
    }




I’m not saying that this view adds any more value than the standard refiner view, in the screenshot above it actually looks pretty poor.

The interesting part about the web part is the use of the refinement manager, it returns the results of the refinement process in xml form. This is really powerful, it means that we could potentially create some really creative visuals around the search results. It will be interesting to watch the community to see what types of variations come out.

Wednesday, February 24, 2010 7:46:00 PM (E. Australia Standard Time, UTC+10:00)  #    Comments [1] - Trackback
code | SharePoint 2010
# Saturday, February 20, 2010

If you’ve ever built a custom protocol handler for MOSS before you may have in the past used the object model to create the content source, since there is no way in Central Admin to do this.

 

Something like:

 

SearchContext context = SearchContext.GetCurrent(spSite);

Content content = new Content(context);

CustomContentSource source = (CustomContentSource)content.ContentSources.Create( ...
source.Update();

But the SearchContext in SharePoint 2010 is marked as obsolete, which makes total sense when you consider that the SSP is no more, it’s been replaced by service applications.

 

The good news is that we can use Powershell to create the custom content source:

 

> $sapp = Get-SPEnterpriseSearchServiceApplication –Identity “Search Service Application”

>New-SPEnterpriseSearchCrawlContentSource –SearchApplication $sapp –Name “Custom Source Name” –Type Custom –StartAddress  protocol://servername –CrawlPriority Normal –MaxPageEnumerationDepth 1 –MaxSiteEnumerationDepth 1

 

 

So much easier …

 

Also when you register your custom protocol handler for SharePoint 2010, remember that the registry hive location now has the number ‘14.0’ in its path:

 

HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Office  Server/14.0/Search/Setup/ProtocolHandlers

 

I still need to have a good play the new BCS stuff in SharePoint 2010, but looking at this post by Todd Baginski I have a feeling that we might have a few more tricks up our sleeves before we go down the custom protocol handler or FAST pipeline route.

Saturday, February 20, 2010 9:36:00 AM (E. Australia Standard Time, UTC+10:00)  #    Comments [1] - Trackback
Search | SharePoint 2010

In MOSS 2007 we could use the codeplex faceted search solution to provide what is now called ‘Search Refiners’ in SharePoint 2010.

 

By default the standard refiner will look like this:

 

image

 

The really nice thing about the refiner is that it will only show a value if a search result is returned for it, so a user will never be faced with clicking on an option and have it return zero results.

But those of us who are familiar with the old faceted search solution will know that the web part displays a count of the results, well the SharePoint 2010 refiner can as well:

 

image

Notice the subtle counts next to the metadata property.

 

This can be achieved by adding the following XML attribute to the refiners configuration xml:

 

Find the <Category>  element that you wish to display counts for and add:   ShowCounts=”Count”

Saturday, February 20, 2010 9:21:00 AM (E. Australia Standard Time, UTC+10:00)  #    Comments [2] - Trackback
Search | SharePoint 2010
Statistics
Total Posts: 191
This Year: 4
This Month: 0
This Week: 0
Comments: 41