Sent to you by Tinh Do via Google Reader:
via SharePoint Team Blog by sharepointblog@live.com on 1/9/13
Hi there. I'm Kerem Yuceturk, a program manager in the SharePoint Enterprise Content Management team. I am truly excited to start talking about the Content Search Web Part, one of the most interesting features that we added to SharePoint 2013, and the many scenarios it enables for SharePoint aficionados around the world.
Before I start to talk about Content Search, let me first set the stage by briefly outlining what this Web Part is trying to accomplish. If you ever dealt with publishing scenarios like creating an intranet portal or a knowledge management solution back in SharePoint 2007 and 2010 days, there is a good chance that you were using the Content Query Web Part. Content Query is great for showing dynamic content based on a set of criteria that you've set. So if you wanted to show a list of news articles on the intranet homepage, or to roll up a list of sales reports on your knowledge center, Content Query was the way to do it.
There was one catch though: If you ever wanted to show items that were not in the same site collection, you were out of luck. The scope of the Content Query Web Part was (and still is) limited to the site collection that the Web Part is placed in.
In SharePoint 2013, FAST Search and SharePoint Search fused together and got deeply integrated into SharePoint. As part of that change, we added a new tool for publishing content for your intranet or Internet site that knows no site-collection boundaries. This tool is the Content Search Web Part.
Content Search can show anything that's in the search index including content across site collections, and even content that comes from outside of SharePoint as long as it was crawled and placed in the search index. If search crawls it, you can display it, no matter where the content lives—provided the user viewing the page has permissions to see the item in question. Plus, thanks to the analytics capabilities that are built into SharePoint 2013, it can also show recommendations and popular items based on usage patterns.
If this sounds like something you want to try out, you can find Content Search in your SharePoint farms by going to the Web Part adder, and choosing the Content Rollup category. (Content Search is not available on Office 365 right now, but we are working on enabling it in the future.)
Figure 1. Two Content Search Web Parts from different contexts: on the left an intranet site that displays some PowerPoint files from another site collection, on the right the Contoso Electronics site that displays some items from the product catalog
At a very high level, using Content Search is easy by following these two steps:
- Choose the items to show (formulate a search query that will return those items as results).
- Format the items the way you want (use Display Templates to customize how items look).
Choosing the items to show
The Content Search Web Part boasts a full-screen query builder that has several preconfigured queries to get you started, and a panel for previewing the results to enable you to tweak your query. It's fully integrated with the new search concepts of SharePoint 2013, like Results Sources and Query Rules, and can use these to get to results. It also has an advanced mode: basically, an enlarged search box where you can write any query using Keyword Query (KQL) syntax, which you can then try out by using the preview panel.
Figure 2. Query builder with tools on the left and preview of results on the right
Content Search also supports a rich set of dynamic values (also called query variables) to be used in queries such as today's date, the name of the current user, any field from the current page, or a custom property from the current web's property bag. Query Builder and dynamic values each deserve blog posts of their own, but for now, you can try out the following query variables in your queries if you want to explore some of the possibilities:
{Today-7}: The date for a week ago, great for "what's new this week" queries.
{User.Name}: The name of the current user. Great for surfacing content for the user who is viewing the page. Also works for any property, including custom properties from the current user's profile.
{Page.MyCustomTextField}: Gets the value of a field that you added to the content type you're using on the page.
{Site.URL}: Gets the current site's URL, or any custom property. Also works for SiteCollection.
{Term}: The current term from managed navigation. For more information, see the blog post Getting friendly with FURLs.
Formatting the items the way you want: Display templates
One of the main pain points we kept hearing from customers was about how irritating it is to use XSL to format the output of a Content Query Web Part. XSL is a relatively obscure web technology and it has a reputation for making most seasoned folks go scratch their heads about the syntax whenever they try to do something a little unusual while formatting the results.In SharePoint 2013, there is a new way to format items shown in Content Search Web Parts using HTML and JavaScript instead of XSL: Display templates.
Display templates make it significantly easier to:
- Specify what managed properties to retrieve from search.
- Manipulate values of the retrieved managed properties in JavaScript, as needed.
- Display the values in HTML in the browser.
Figure 3. Same search results displayed using three different sets of display templates in each of the columns
Display templates are located in the master page gallery of your site collection. There are several display templates that come pre-installed in a folder named Display Templates for your convenience, so feel free to browse around that folder if you'd like to get a feel for them. The best way to create a new display template is to copy one of the existing ones, and change its properties and content. Note that you should always deal with the .html files in those folders; .js files are auto-generated by SharePoint whenever you modify an .html file of the same name.
Display templates also deserve another blog post to do that topic any justice, so let me wrap this section up here to keep this post short and sweet.
Conclusion
I hope this gave you a taste of what the Content Search Web Part can do for you in your SharePoint deployments. Be sure to look for future posts that will go into more detail about some of the concepts introduced here.Things you can do from here:
- Subscribe to SharePoint Team Blog using Google Reader
- Get started using Google Reader to easily keep up with all your favorite sites
No comments:
Post a Comment