i:0#.w|Ali.Mazaheri

SharePoint, SharePoint and SharePoint!

Customizing High Confidence Search Result for People search in MOSS 2007

Customizing High Confidence Search Result for People search in MOSS 2007

Rate This
  • Comments 4

OOTB when searching for a person using "PreferredName", "WorkEmail", "UserName" and "AccountName", along with the core search result (Displayed via Search Core Result webpart) person's information is also displayed using "Search High Confidence Results" webpart (Same webpart used for Best bet) as exact match.

image

By default following properties are included in the high confidence search result:

  • Title
  • Skills
  • Work Email
  • Work Phone
  • Department
  • Office
  • About Me
  • Responsibility

Following steps allows administrators to add additional information (e.g. Cell Phone or any custom profile property) to the resultset.

Step 1

From "Metedata Property Mapping" page select and edit any of the available High Confidence Display Properties (HighConfidenceDisplayProperty12-HighConfidenceDisplay15):

image

And from "Edit Managed Property" page map it to the desired profile property:

image

Step 2

Run a full crawl on a content source which contains sps3://[Mysite web application url] as one of the entries in start addresses list:

image

Step 3

On "results.aspx" or "peopleresults.aspx" replace the "Search High Confidence Results" webpart's XSLT with the following:

XML

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>
</xsl:template>
</xsl:stylesheet>

And make sure that the profile property added in step 1 is included in the resultset:

image

Note: Make sure to save the original XSLT before applying the above change. 

Step 4

Add a reference to the "highconfidencedisplayproperty12" in the original XSLT as follows:

XML

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:param name="BBLimit">3</xsl:param>

<xsl:param name="DisplayDefinition">True</xsl:param>

<xsl:param name="DisplayDescription">False</xsl:param>

<xsl:param name="DisplayHCDescription">False</xsl:param>

<xsl:param name="DisplayHCImage">True</xsl:param>

<xsl:param name="DisplayHCProps">True</xsl:param>

<xsl:param name="DisplayHCTitle">True</xsl:param>

<xsl:param name="DisplayTerm">True</xsl:param>

<xsl:param name="DisplayTitle">True</xsl:param>

<xsl:param name="DisplayUrl">True</xsl:param>

<xsl:param name="ResultsPerTypeLimit">1</xsl:param>

<xsl:param name="DisplayST">True</xsl:param>

<xsl:param name="DisplayBB">True</xsl:param>

<xsl:param name="DisplayHC">True</xsl:param>

<xsl:param name="ResponsibilityText" />

<xsl:param name="SkillsText" />

<xsl:param name="HighConfTitle" />

<xsl:param name="IsFirstPage">True</xsl:param>

<xsl:param name="BestBetTitle"></xsl:param>

<xsl:template match="All_Results/SpecialTermInformation">

 <xsl:variable name="keyword" select="Keyword" />

 <xsl:if test="$DisplayST = 'True'" >

   <xsl:if test="($DisplayTerm = 'True'and string-length($keyword) &gt; 0) or ($DisplayDefinition = 'True' and string-length(Description) &gt; 0)" >

     <div class="srch-BB-SpecialTerm">

       <xsl:if test="$DisplayTerm = 'True'and string-length($keyword) &gt; 0"> 

         <span class="srch-BB-SpecialTerm">

           <img src="http://blogs.msdn.com/_layouts/images/star.gif" alt="" />

           <b>

           <xsl:value-of select="$keyword"/>

           </b>

         </span>

       </xsl:if>

       <xsl:if test="$DisplayDefinition = 'True'" >     

         <xsl:value-of disable-output-escaping="yes" select="Description"/>

       </xsl:if>  

     </div> 

   </xsl:if>  

 </xsl:if>

</xsl:template>

<xsl:template match="All_Results/BestBetResults/Result">

 <xsl:if test="$DisplayBB = 'True'" >

  <xsl:if test="position() &lt;= $BBLimit" >

  <xsl:variable name="url" select="url"/>

  <xsl:variable name="id" select="id" />

  <div class="srch-BB-Result">

  <xsl:if test="$DisplayTitle = 'True'" >

    <span class="srch-BestBetsTitle">

     <img src="http://blogs.msdn.com/_layouts/images/sts_site16.gif" alt="" />

     <a href="{$url}" id="{concat('BBR_',$id)}">

      <xsl:value-of select="title"/>

     </a>

    </span>

  </xsl:if>

  <xsl:if test="$DisplayDescription = 'True' and description[. != '']" >

      <div class="srch-BB-Description">

      <xsl:value-of select="description"/>

      </div>

  </xsl:if>

  <xsl:if test="$DisplayUrl = 'True'" >

     <span class="srch-BB-URL">

     <a href="{$url}" id="{concat('BBR_U_',$id)}" dir="ltr">

      <xsl:value-of select="$url"/>

     </a>

     </span>

  </xsl:if>

  </div>

  </xsl:if>

 </xsl:if>  

</xsl:template>

<xsl:template match="All_Results/HighConfidenceResults/Result">

 <xsl:if test="$DisplayHC = 'True' and $IsFirstPage = 'True'" >

  <xsl:variable name="prefix">IMNRC('</xsl:variable>

  <xsl:variable name="suffix">')</xsl:variable>

  <xsl:variable name="url" select="url"/>

  <xsl:variable name="id" select="id"/>

  <xsl:variable name="pictureurl" select="highconfidenceimageurl"/>

  <xsl:variable name="jobtitle" select="highconfidencedisplayproperty1"/>

  <xsl:variable name="workphone" select="highconfidencedisplayproperty2"/>

  <xsl:variable name="department" select="highconfidencedisplayproperty3"/>

  <xsl:variable name="officenumber" select="highconfidencedisplayproperty4"/>

  <xsl:variable name="preferredname" select="highconfidencedisplayproperty5"/>

  <xsl:variable name="aboutme" select="highconfidencedisplayproperty8"/>

  <xsl:variable name="responsibility" select="highconfidencedisplayproperty9"/>

  <xsl:variable name="skills" select="highconfidencedisplayproperty10"/>

  <xsl:variable name="workemail" select="highconfidencedisplayproperty11"/>

  <xsl:variable name="cellphone" select="highconfidencedisplayproperty12"/>

  <div class="srch-HCMain ">

  <span class="srch-HCSocDistTitle">

    <xsl:value-of select="$HighConfTitle" />

  </span>

  <table class="psrch-HCresult" CELLPADDING="0" CELLSPACING="0" BORDER="0" width="100%">

    <tr>

      <td class="psrch-imgcell" width="0%">

        <xsl:if test = "$DisplayHCImage = 'True'">

          <table class="psrch-profimg" CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="77px" HEIGHT="77px">

            <tr>

              <td align="middle" valign="middle">

                <a href="{$url}" id="{concat('HSR_IMGL_',$id)}" title="{$url}">

                  <xsl:variable name="imgid" select="concat('HSR_IMG_',$id)"/>

                  <xsl:choose>

                    <xsl:when test = "string-length($pictureurl) &gt; 0">

                      <img id="{$imgid}" src="{$pictureurl}" alt="{$preferredname}" border="0" onload="resizeProfileImage('{$imgid}')"/>

                    </xsl:when>

                    <xsl:otherwise>

                      <img id="{$imgid}" src="http://blogs.msdn.com/_layouts/images/no_pic.gif" alt="{$preferredname}" border="0" onload="resizeProfileImage('{$imgid}')"/>

                    </xsl:otherwise>

                  </xsl:choose>

                  <script>

                    window.setTimeout("resizeProfileImage('<xsl:value-of select="$imgid"/>')", 1)

                  </script>

                </a>

              </td>

            </tr>

          </table>

        </xsl:if>

      </td>

      <td valign="top" class="psrch-propcell" width="100%">

        <span class="psrch-Title">

          <img border="0" height="12" width="12" src="http://blogs.msdn.com/_layouts/images/imnhdr.gif" onload="{concat($prefix, $workemail, $suffix)}" ShowOfflinePawn="1" id="{concat('HSRP_',$id)}" />

          <a href="{$url}" id="{concat('HSR_',$id)}">

            <xsl:value-of select="$preferredname"/>

          </a>

        </span>

        <br/>

        <div class="psrch-Description">

          <xsl:call-template name="DisplayOfficeProfile">

            <xsl:with-param name="title" select="$jobtitle" />

            <xsl:with-param name="dep" select="$department" />

            <xsl:with-param name="phone" select="$workphone" />

            <xsl:with-param name="office" select="$officenumber" />

            <xsl:with-param name="cell" select="$cellphone" />

          </xsl:call-template>

        </div>

        <div class="psrch-Description">

          <xsl:choose>

            <xsl:when test="$aboutme[. != '']">

              <xsl:value-of disable-output-escaping="yes" select="$aboutme"/>

              <br/>

            </xsl:when>

          </xsl:choose>

          <xsl:choose>

            <xsl:when test="$responsibility[. != ''] or $skills[. != '']">

              <xsl:choose>

                <xsl:when test="$responsibility[. != '']">

                  <span class="psrch-PropLabel">

                    <xsl:value-of disable-output-escaping="yes" select="$ResponsibilityText"/>

                  </span>

                  <span class="psrch-PropValue">

                    <xsl:value-of select="translate($responsibility,';',',')"/>

                    <xsl:text> </xsl:text>

                  </span>

                </xsl:when>

              </xsl:choose>

              <xsl:choose>

                <xsl:when test="$skills[. != '']">

                  <xsl:if test="$responsibility[. != ''] and $skills[. != '']">

                    <br/>

                  </xsl:if>

                  <span class="psrch-PropLabel">

                    <xsl:value-of disable-output-escaping="yes" select="$SkillsText"/>

                  </span>

                  <span class="psrch-PropValue">

                    <xsl:value-of select="translate($skills,';',',')"/>

                  </span>

                </xsl:when>

              </xsl:choose>

              <br/>

            </xsl:when>

            <xsl:otherwise><span /></xsl:otherwise>

          </xsl:choose>

        </div>

      </td>

    </tr>

  </table>         

  </div>

 </xsl:if>  

</xsl:template>

<!-- XSL transformation starts here -->

<xsl:template match="/">

    <xsl:call-template name="dvt_1.body"/>    

</xsl:template>

<xsl:template name="DisplayOfficeProfile">

  <xsl:param name="title" />

  <xsl:param name="dep" />

  <xsl:param name="phone" />

  <xsl:param name="office" />

  <xsl:param name="cell" />

 

  <span class="psrch-Metadata">

  <xsl:if test='string-length($title) &gt; 0'>  

   <xsl:value-of select="$title" /> 

   -

  </xsl:if>

  <xsl:if test='string-length($dep) &gt; 0'>  

   <xsl:value-of select="$dep" /> 

   -

  </xsl:if>

  <xsl:if test='string-length($phone) &gt; 0'>  

   <xsl:value-of select="$phone" /> 

   -

  </xsl:if>

  <xsl:if test='string-length($office) &gt; 0'>  

   <xsl:value-of select="$office" /> 

    -

  </xsl:if>

  <xsl:if test='string-length($cell) &gt; 0'>

<xsl:value-of select="$cell" />

</xsl:if>

  </span>

  <br/>

</xsl:template>

<xsl:template name="dvt_1.body">

  <xsl:apply-templates />

</xsl:template>

<!-- End of Stylesheet -->

</xsl:stylesheet>

Replace the customized XSLT with the original version and check in the page to apply the changes.

image

  • PingBack from http://stevepietrek.com/2008/12/04/links-1242008-2/

  • Steve,

    We are experiencing an issue shown on the last graphic of your blog.

    When a user does not have an "About Me" filled out in their profile...each user returned in the search results under "Everyone Else" (i.e. Mary johnson)has variables that should not be printed on the screen.  For example, on the last graphic on your post...you have the same issue, for example:

    "MOSS-DEV-1\MaryJ Mary Jonson Mary Johnson (310) 804-5555 MaryJ@Contoso.com..."

    Can we edit the XSLT to not show "extra info" without populating everyone's "About Me"?

    Thanks,

    John

  • Hi John,

    This is by design and my customer removed "Above Me" from search results.

  • How to create more than 15 High Confidence Properties, its not working if i create High Confidence Property 15,please guide me how to do this.. Thanks,ravi

Page 1 of 1 (4 items)
Leave a Comment
  • Please add 2 and 7 and type the answer here:
  • Post