Skip to main content

Cloud

When adding managed properties to your search results, be careful to watch the case of the property name because SharePoint may change it on you.

Once you move an organization beyond the basic search configuration, you will at some point begin to use managed properties to enhance and improve the search experience. One of the more common uses of managed properties in search is to include more information in your search results. Only those crawled properties that you explicitly map into manages properties are available to your search results web parts.
The process of adding a managed property to your search results is very straight forward and is well documented in the SDK article, How To: Change the Properties Returned in the Core Search Results. Simply stated, you open up the core results web part and you add the managed properties that you want in an XML file that you access through the properties pane.
After adding the property to the core results web part, it becomes available to your search results xsl file. Using the XSL editor in the search web part, you can include <xsl:value-of select="" /> statements to include the managed property in your search results interface.
The problem that may hang you up the first time that you try to include a property is that SharePoint may change the case of your managed property’s name if you have used any capital letters in the property name. Specifically, SharePoint will convert your managed property names to all lowercase letters when it returns search results to the core results web part.
I highlight the term search results above because you will need to handle your managed property name differently based on whether you are adding the property to the web part or adding the property to the XSL. In short, you will need to use the case that you used when defining the property name when you add it to the properties XML but you must convert it to all lowercase when you add the property to the XSL.
As an example: I use Camel-case spelling for my managed property names. In a recent project, I created managed properties called EmployeeFirstName, EmployeeLastName, and EmployeeTitle which were mapped to crawled properties from a BDC data source. When adding the properties to the query properties, I use the camel-case spelling in the XML file.
<Column Name="EmployeeFirstName" />
<Column Name="EmployeeLastName" />
<Column Name="EmployeeTitle" />
On the other hand, when I include these same properties in the XSL file for the search results display, I must remember to make the names lower case or I will get nothing in my results. So my XSL will look like:
<xsl:value-od select="employeefirstname"/><xsl:text> </xsl:text><xsl value-of select="employeelastname"/>
You may be wondering how to view the raw xml that SharePoint returns in the search results. It happens that the MSDN article How To: View Search Results XML Data is an excellent walk-through that will reveal the raw results and the case of property names that you want to use in your search results.
An interesting side note, for those of you who use the Mondosoft Ontolica product: It does NOT change the case of your managed properties.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Dave Scheele

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram