SharePoint Products TechCenter > SharePoint Products and Technologies Forums > SharePoint - Search > How to include a document library column in a search result?
Ask a questionAsk a question
 

AnswerHow to include a document library column in a search result?

  • Tuesday, October 27, 2009 12:17 PMGopi Ramaya Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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

  • Tuesday, October 27, 2009 2:30 PMCoreyRoth Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    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

  • Tuesday, October 27, 2009 2:30 PMCoreyRoth Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    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
    •  
  • Wednesday, October 28, 2009 3:53 AMGopi Ramaya Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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
  • Tuesday, November 03, 2009 3:22 PMCoreyRoth Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Booktype would be empty in that case.
    Corey Roth blog: www.dotnetmafia.com twitter: twitter.com/coreyroth