I am trying to add rating stars to the search results in my Enterprise Search Center site according to the instructions found on the following sites:

MSDN | Corey Roth - MVP's Blog | Todd's Blog

The instructions were simple enough to follow, but when I search I cannot get the stars to appear. I have tried a number of different things at this point but I am not aware of any XSL debugger, so I have been at a loss. I know the ratings have been crawled because I was able to successfully search for items with specific ratings.

Anybody else have this problem (and hopefully a solution)?


  • Matt

EDIT 3/14/2012:

Following is the XSL I added to the Core Search Results web part:

In the bottom of the div with the class "srch-Title3":

<!--Start Rating-->
<xsl:call-template name="FormatRating">
    <xsl:with-param name="theRating" select="rating"/>
    <xsl:with-param name="theRatingCount" select="ratingcount"/>
<!--End Rating-->

In the bottom of the XSL sheet, before </xsl:stylesheet>:

<!--Start Rating-->
<xsl:template name="FormatRating">
    <xsl:param name="theRating"/>
    <xsl:param name="theRatingCount"/>
   <xsl:if test="$theRating > 0">
     <div style="display: inline-block; padding-left: 8px;">
         <xsl:variable name="tempTitle" select="concat($theRating, ' Stars (')"/>
         <xsl:variable name="tempTitle2" select="concat($theRatingCount, ' Ratings)')"/>
         <xsl:variable name="ratingTitle" select="concat($tempTitle, $tempTitle2)"/>

         <xsl:attribute name="title">
           <xsl:value-of select="$ratingTitle"/>
           <xsl:when test="round($theRating) = 0 and $theRating &gt; 0">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-368px 0px;width:16px;</xsl:attribute>
           <xsl:when test="round($theRating) = 1 and round($theRating) &lt;= $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-352px 0px;width:16px;</xsl:attribute>
           <xsl:when test="round($theRating) = 2 and round($theRating) &gt; $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-352px 0px;width:32px;</xsl:attribute>
           <xsl:when test="round($theRating) = 2 and round($theRating) &lt;= $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-336px 0px;width:32px;</xsl:attribute>
           <xsl:when test="round($theRating) = 3 and round($theRating) &gt; $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-336px 0px;width:48px;</xsl:attribute>
           <xsl:when test="round($theRating) = 3 and round($theRating) &lt;= $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-320px 0px;width:48px;</xsl:attribute>
           <xsl:when test="round($theRating) = 4 and round($theRating) &gt; $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-320px 0px;width:62px;</xsl:attribute>
           <xsl:when test="round($theRating) = 4 and round($theRating) &lt;= $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-304px 0px;width:64px;</xsl:attribute>
           <xsl:when test="round($theRating) = 5 and round($theRating) &gt; $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-304px 0px;width:80px;</xsl:attribute>
           <xsl:when test="round($theRating) = 5">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-160px 0px;width:80px;</xsl:attribute>
<!--End Rating-->
  • I will say that I was able to search using Rating=4.0 and get results. My problem is just displaying the results as either a number or stars.
    – Matt
    Commented May 21, 2012 at 15:56

1 Answer 1


without digging into the XLST it's almost impossible to guess at an answer. I'd suggest you fall back to Cory's display method of showing the rating as Text to verify that you're getting the value properly into the results and then look at incorporating the flash graphics.

  • There are no flash graphics. It is just html and css, but that is besides the point. I pretty much copied and pasted from Todd's blog, naming my fields "Rating" and "RatingCount," respectively. I tried doing Cory's method, in addition. Per your suggestion, I commented out the part that calls the xsl template and replaced it with a simple call to the managed property (all lower-case for some reason, like the examples) and I got nothing.
    – Matt
    Commented Mar 12, 2012 at 21:48
  • does your property show up if you use the MSDN XSLT that lists all the managed properties?
    – GavinB
    Commented Mar 13, 2012 at 22:24
  • used the following code <xsl:for-each select="@*"> <br /> Name: <xsl:value-of select="name()" /> Value:<xsl:value-of select="." /> </xsl:for-each> but no dice
    – Matt
    Commented Mar 14, 2012 at 15:53
  • You added the new managed property to the list of columns to be selected right?
    – GavinB
    Commented Mar 14, 2012 at 19:47
  • Yes, I also tried adding it to the parameters section for the xsl, but that caused it to break even more (no search results would display at all)
    – Matt
    Commented Mar 14, 2012 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.