SharePoint Products TechCenter >
SharePoint Products and Technologies Forums
>
SharePoint - Search
>
How to include a document library column in a search result?
How to include a document library column in a search result?
- Hi all,I have a custom list named Book which contains a column named BookType and i want to display the booktype values in my search results.How can i add BookType column in XSLT file ?
- Gopi Ramaya
Answers
- This is pretty easy to do. First, you need to add that BookType column as a managed property. Go to your SSP, create a new managed property and then map it to the crawled property. In your case, it should be under SharePoint and will probably be called something like ows_BookType. If the crawled property doesn't show up yet, you need to do a full crawl first. Once you map the managed property, you need to do another full crawl.
After that, you can edit the results page, you then need to add the column to the selected columns, it would look something like this.
<Column Name="BookType" />
You can then add the column to your XSLT to show in the results, look for <xsl:template match="Result"> and then look for a suitable place in the XSL to put your text. It would look something like this. The name of your column here needs to be specified in lower case.
<div class="srch-Description">
Book Type: <xsl:value-of select="booktype" />
</div>
For complete instructions, check out my post on customizing search results.
Corey Roth blog: www.dotnetmafia.com twitter: twitter.com/coreyroth- Marked As Answer byGopi Ramaya Wednesday, October 28, 2009 3:53 AM
All Replies
- This is pretty easy to do. First, you need to add that BookType column as a managed property. Go to your SSP, create a new managed property and then map it to the crawled property. In your case, it should be under SharePoint and will probably be called something like ows_BookType. If the crawled property doesn't show up yet, you need to do a full crawl first. Once you map the managed property, you need to do another full crawl.
After that, you can edit the results page, you then need to add the column to the selected columns, it would look something like this.
<Column Name="BookType" />
You can then add the column to your XSLT to show in the results, look for <xsl:template match="Result"> and then look for a suitable place in the XSL to put your text. It would look something like this. The name of your column here needs to be specified in lower case.
<div class="srch-Description">
Book Type: <xsl:value-of select="booktype" />
</div>
For complete instructions, check out my post on customizing search results.
Corey Roth blog: www.dotnetmafia.com twitter: twitter.com/coreyroth- Marked As Answer byGopi Ramaya Wednesday, October 28, 2009 3:53 AM
- CoreRoth,
Many thanks for your reply....
If some of my sharepoint list doesn't have this column what will be the value returned for Booktype.
- Gopi Ramaya - Booktype would be empty in that case.
Corey Roth blog: www.dotnetmafia.com twitter: twitter.com/coreyroth

