Showing posts with label Rating Search Results XSL. Show all posts
Showing posts with label Rating Search Results XSL. Show all posts

Thursday, April 15, 2010

Display SharePoint 2010 ratings in search results XSL

I had a requirement to show the ratings(new feature in Sharepoint 2010) for all items that are returned in search results.

The crawled property that we have to use to get to the ratings is ows_AverageRating. You first need to create a metadata property like AverageRating that maps to the crawled property ows_AverageRating(decimal) to be able to display rating in search results. After adding the property, make sure that you run a full crawl so that the indexer picks up all the ratings.

After adding the property and performing a full crawl, we can use the below XSL to display rating for each item in search results.



 
   
  
    
  
  
    
  
  
    
  
   
   

 
   No Rating
   





 
 
 
   
   
  
  
   
 


Note: I have used 2 icons ratings_halfstar_blue.png and ratings_star_blue.png which are free to download. Make sure that you upload them some where and adjust the paths accordingly.

Ref: http://blogs.technet.com/speschka/archive/2009/10/28/using-the-new-sharepoint-2010-ratings-feature-in-search.aspx