Search Web Parts Mike Maadarani MCM Consulting
Mike Maadarani MCM Consulting App Dev and Architecture for over 21 years (18 Years Microsoft, 3 Years with the “Other Guys”) Business focused on Enterprise Content Management, Search, & Publishing Sites Architect, trainer, and presenter Email : mike@Maadarani.com Twitter : @mikemaadarani Facebook : mike.maadarani LinkedIn : mikemaadarani
Content Search Web Part Agenda Query Language Display Templates Content Search Web Part Introduction Demos Closing and Q&A
Walk back in the past
Microsoft SharePoint Server 2013 Problems in the past Aggregation info from multiple lists/libraries Cross Site Collections data sharing Contextual Results Branding the results Performance Aggregation using custom web parts or content query web part Contextual search: searching within the site you are on © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2013 Previous Solutions Content Web Part Search What’s XSLT again? Coding © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2013 Our lovely XSLT <!-- When empty result set is returned from search --> <xsl:template name=""> <div class="srch-results"> <xsl:if test="string-length($SrchRSSLink) > 0 and $ShowActionLinks"> <a type="application/rss+xml" href ="{$SrchRSSLink}" title="{$SrchRSSText}" id="SRCHRSSL" class="srch-ext-action-margin"> <img style="vertical-align: middle;" border="0" src="/_layouts/images/rss.gif" alt=""/> <xsl:text disable-output-escaping="yes"> </xsl:text> <xsl:value-of select="$SrchRSSText"/> </a> <xsl:if test="string-length($SearchProviderLink) > 0"> | <a href ="{$SearchProviderLink}" title="{$SearchProviderText}" class="srch-ext-action-margin" > <img style="vertical-align: middle;" border="0" src="/_layouts/images/searchfolder.png" alt=""/> <xsl:text disable-output-escaping="yes"> </xsl:text> <xsl:value-of select="$SearchProviderText"/> </a> </xsl:if> </xsl:if> </div> © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2013 Branding CQWP <xsl:template name="ImageRight" match="Row[@Style='ImageRight']" mode="itemstyle"> ///The <xsl:variable> sections process and ensure correct formatting of the data. ///This section declares the variable named SafeLinkUrl, includes instructions to call the OuterTemplate.GetSafeLink function, and includes the LinkUrl expression to scope the call to the UrlColumnName parameter. - <xsl:variable name="SafeLinkUrl"> /// The OuterTemplate.GetSafeLink variable passes in the UrlColumnName that represents the column name containing the ItemUrl. - <xsl:call-template name="OuterTemplate.GetSafeLink"> <xsl:with-param name="UrlColumnName" select="'LinkUrl'" /> </xsl:call-template> </xsl:variable> ///This section declares the variable named SafeImageUrl and calls the OuterTemplate.GetSafeStaticUrl function. - <xsl:variable name="SafeImageUrl"> - <xsl:call-template name="OuterTemplate.GetSafeStaticUrl"> <xsl:with-param name="UrlColumnName" select="'ImageUrl'" /> </xsl:call-template> </xsl:variable> ///This section declares the variable named SafeImageHtml and calls the OuterTemplate.GetColumnDataForUnescapedOutput function, and passes the 'PublishingRollupImage' and 'Image' parameter values to the template rule. - <xsl:variable name="SafeImageHtml"> - <xsl:call-template name="OuterTemplate.GetColumnDataForUnescapedOutput"> <xsl:with-param name="Name" select="'PublishingRollupImage'" /> <xsl:with-param name="MustBeOfType" select="'Image'" /> </xsl:call-template> </xsl:variable> ///This section declares the variable named DisplayTitle, includes calls to the OuterTemplate.GetTitle function, and passes the @Title and 'LinkUrl' parameter values to the template rule. - <xsl:variable name="DisplayTitle"> - <xsl:call-template name="OuterTemplate.GetTitle"> <xsl:with-param name="Title" select="@Title" /> <xsl:with-param name="UrlColumnName" select="'LinkUrl'" /> </xsl:call-template> </xsl:variable> ///This section declares the variable named LinkTarget and tests whether it should open the target URL in a new window. If the test returns True, then the template rule processes the instruction to open the target URL in a new window. - <xsl:variable name="LinkTarget"> <xsl:if test="@OpenInNewWindow = 'True'">_blank</xsl:if> </xsl:variable> ///The <div> sections define the data to render and provide instructions on how to render it. This code block defines item data, and uses the OuterTemplate.CallPresenceStatusIconTemplate function to verify whether it should create an icon. - <div class="item"> <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate" /> ///The <xsl:if test> instruction supplies a condition for the XSLT engine to evaluate. If the test evaluates to True after converting it to a Boolean value, the ItemStyle renders the content. - <xsl:if test="string-length($SafeImageUrl) = 0 and string-length($SafeImageHtml) != 0"> - <div class="image-area-right"> <xsl:value-of disable-output-escaping="yes" select="$SafeImageHtml" /> </div> </xsl:if> - <xsl:if test="string-length($SafeImageUrl) != 0"> - <div class="image-area-right"> - <a href="{$SafeLinkUrl}" target="{$LinkTarget}"> <img class="image" align="left" border="0" src="{$SafeImageUrl}" alt="{@ImageUrlAltText}" /> </a> </div> </xsl:if> - <div class="link-item"> - <a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}"> <xsl:value-of select="$DisplayTitle" /> </a> - <div class="description"> <xsl:value-of select="@Description" /> </div> </div> </div> </xsl:template> <xsl:for-each select="@*"> F:<xsl:value-of select="name()"/>–<xsl:value-of select="."/><br/> </xsl:for-each> <a href="{substring-before(@URLColumn, ‘, ‘)}"> <xsl:value-of select="substring-after(@URLColumn, ‘, ‘)"/> </a> <div class="image-area-left"> <xsl:value-of select="@Icon" disable-output-escaping="yes"/> </div> <xsl:variable name="ListGuid"> <xsl:value-of select="@ListId"/> </xsl:variable> <xsl:variable name="ItemId"> <xsl:value-of select="@ID"/> </xsl:variable> <div> <xsl:choose> <xsl:when test="contains($Rating, ‘(5)’)"> <img src="/_layouts/images/sptoolbasket/rating_5.gif" alt="{$Rating}"/> </xsl:when> <xsl:when test="contains($Rating, ‘(4)’)"> <img src="/_layouts/images/sptoolbasket/rating_4.gif" alt="{$Rating}"/> </xsl:when> <xsl:when test="contains($Rating, ‘(3)’)"> <img src="/_layouts/images/sptoolbasket/rating_3.gif" alt="{$Rating}"/> </xsl:when> <xsl:when test="contains($Rating, ‘(2)’)"> <img src="/_layouts/images/sptoolbasket/rating_2.gif" alt="{$Rating}"/> </xsl:when> <xsl:when test="contains($Rating, ‘(1)’)"> <img src="/_layouts/images/sptoolbasket/rating_1.gif" alt="{$Rating}"/> </xsl:when> <xsl:otherwise> <a href="/_layouts/sptoolbasket/ItemRating.aspx?Id={$ItemId}&List={$ListGuid}">Rate</a> </xsl:otherwise> </xsl:choose> </div> © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Back to the Future
Search Driven Portals Content Search Usage DOCUMENTS ARTICLES ASSET LIBRARY DOCUMENTS ARTICLES CATALOG NAVIGATION
Microsoft SharePoint Server 2013 Search Driven Content Crawl, process, index Load page, evaluate query Display templates render results. Content Search Publishing Portal User Experience Document libraries Index Content Search WP (CSWP) Crawl & doc. processing Query processing Query Lists Display Templates Analytics © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Content Search Web Part (CSWP) Microsoft SharePoint Server 2013 Content Search Web Part (CSWP) © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
CSWP Demo
Microsoft SharePoint Server 2013 Search Schema Content Content Processing Index CSWP Crawled properties Managed properties Managed properties Office:2 Title People:PreferredName Basic:displayTitle Ows_Title Basic:10 Basic:9 Author (Query, Search, Retrieve, Sort) Title (Search, Query, Retrieve) LastModified (Query, Retrieve, Refine, Sort) © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2013 Search Schema Automatic creation of properties List columns: crawled property only Site columns: crawled and managed property + mapping Content Search Publishing Portal User Experience Document libraries Index Content Search WP (CSWP) Crawl & doc. processing Query processing Query Lists Display Templates Analytics Crawled properties Managed properties © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2013 The Query Builder © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2013 Where’s my content?! Continuous crawl A mechanism to pick up changes in SharePoint quickly and refresh the index Incremental crawl is less frequent and picks up new libraries What’s the delay about? Balancing scale vs. growth Crawling is paused during some operational gestures What about SPO? Site/List re-index © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Query Builder Demo
Microsoft SharePoint Server 2013 Display Templates © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2013 What does it do? Stored in “~sitecollection/_catalogs/masterpage/Display Templates/” Provides reusable displays for your Content NO MORE XSLT! HTML and JavaScript Uses “Managed Properties” to show the content in right <div> © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2013 Different Categories Different Categories Control Similar to ContentQueryMain.xsl Filter, Group and Hover Panel Similar to Header.xsl +more Item Similar to itemstyle.xsl © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2013 Control The container for the “Groups, Filters and Items” to come Best way to reference custom files (JavaScript, CSS, etc…) © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft SharePoint Server 2013 Item The container for the “Groups, Filters and Items” to come Best way to reference custom files (JavaScript, CSS, etc…) © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Editing a Display Template Microsoft SharePoint Server 2013 Editing a Display Template Consists of 2 files: HTML and JS Never Edit the JS file © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Editing a Display Template Microsoft SharePoint Server 2013 Editing a Display Template Many OOB Templates Never Edit OOB; make a copy No need to copy the JS File; only the HTML © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Display Templates Demo
Complex Queries
Microsoft SharePoint Server 2013 Dynamic Queries Use a single page to display different results Use variables in your query language URL, Parameters, and other filters can be used on load Dynamic re-ordering rules © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
CSWP Loading Behaviour Microsoft SharePoint Server 2013 CSWP Loading Behaviour Use Sync to optimize the most used data Use Async when the user can wait for the data Multiple Sync CSWPs can slow down the entire page: we have to wait for the slowest query! © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Complex Queries Demo
In Review: Session Objectives And Takeaways Microsoft SharePoint Server 2013 In Review: Session Objectives And Takeaways Search Driven Publishing in SharePoint online Content Search Web Part (CSWP) Display templates Search Schema Authenticated cache mechanism Best practices for CSWP Use standard HTML and JavaScript for customization Building search result from different data sources Create an extensible and actionable search User Interface © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.