Friday, 21 August 2015

Configure a Content Search Web Part in SharePoint 2013

Display content by configuring a simple query in a Content Search Web Part


If the query that you want the Content Search Web Part (CSWP) to issue is simple, for example, if you want to limit search results to a result source or to a specific tag, then you’ll probably only need to use the configuration options on the BASICS tab.

  1. Make sure that you’re a member of the Designers SharePoint group on the site that contains the CSWP.
  2. Go to the page that contains the CSWP that you want to edit.
  3. From Settings Small Settings gear that took the place of Site Settings., select Edit Page.
  4. In the Web Part, select the Content Search Web Part Menu arrow > Edit Web Part.
  5. In the Web Part tool pane, in the Properties section, in the Search Criteria section, select Change query.
    A dialog box as shown in the image above opens. Here, you can configure the query as described in the following table.




Select a query
Select a result source to specify which content should be searched.
Restrict results by app
Select an option from the list to restrict results to a specific site, library, list, or URL.
Restrict by tag
You can limit results to content that is tagged with a term.
Select one of the following:
Don’t restrict by any tag
Search results aren’t limited by a term.
Restrict by navigation term of current page
Search results are limited to content that’s tagged with the navigation term of the current page. The navigation term is displayed as the last part of the friendly URL. This option is only meaningful for sites that use managed navigation.
Restrict bycurrent and child navigation
Search results are limited to content that is tagged with the navigation term of the current page (displayed as the last part of the friendly URL), and content that is tagged with sub-terms of the current navigation term. This option is only meaningful for sites that use managed navigation.
NOTE    In a cross-site publishing scenario, this selection will work only when the result source that you selected from the Select a query menu is the catalog result source that was created when you connected your publishing site to a catalog.
Restrict on this tag
Search results are limited to content that is tagged with the tag that you type inside the box.

Display content by configuring an advanced query in a Content Search Web Part



If the query that you want the CSWP to issue is advanced, for example you want to use Keyword Query Language (KQL) Syntax Reference, you’ll need to use the configuration options that are available in Advanced Mode on theBASICS tab.

When you configure the query in Advanced Mode, you can also use query variables. Query variables are placeholders that are replaced with values when a query is run. Examples of query variables are {User.Name}, which is a placeholder for the name of the user who is viewing the page, or {URLToken.1}, which is a placeholder for the first value in the URL as counted from right to left.


  1. Make sure that you’re a member of the Designers SharePoint group on the site that contains the CSWP.
  2. Go to the page that contains the CSWP that you want to edit.
  3. From Settings Small Settings gear that took the place of Site Settings., select Edit Page.
  4. In the Web Part tool pane, in the Properties section, in the Search Criteria section, select Change query.
  5. In the dialog box that opens, select Switch to Advanced Mode.
  6. Configure your query as described in the following tables:


If the query that you want the CSWP to issue is advanced, for example you want to use Keyword Query Language (KQL) Syntax Reference, you’ll need to use the configuration options that are available in Advanced Mode on theBASICS tab.

When you configure the query in Advanced Mode, you can also use query variables. Query variables are placeholders that are replaced with values when a query is run. Examples of query variables are {User.Name}, which is a placeholder for the name of the user who is viewing the page, or {URLToken.1}, which is a placeholder for the first value in the URL as counted from right to left.
  1. Make sure that you’re a member of the Designers SharePoint group on the site that contains the CSWP.
  2. Go to the page that contains the CSWP that you want to edit.
  3. From Settings Small Settings gear that took the place of Site Settings., select Edit Page.
  4. In the Web Part tool pane, in the Properties section, in the Search Criteria section, select Change query.
  5. In the dialog box that opens, select Switch to Advanced Mode.
  6. Configure your query as described in the following tables:
BASICStab
Select a query
Select a result source to specify which content should be searched.
Keyword filter
You can use keyword filters to add query variables to your query. For a list of available query variables, see Query variables in SharePoint Server 2013.
You can select predefined query variables from the drop-down list, and then add them to the query by selecting Add keyword filter.
Property filter
You can use property filters to query the content of managed properties that are set to queryable in the search schema.
You can select managed properties from the Property filter drop-down list. Select Add property filter to add the filter to the query.
Query text
Type your query by using Keyword Query Language (KQL), or use the Keyword filter and Property filter lists to build the query.
The keyword query can consist of free-text keywords, property filters, or operators. Use braces to enclose query variables. Query variables are replaced with an actual value when the query is run.
Keyword queries have a maximum length of 2,048 characters.
REFINERS tab
Use this tab if you want your search results to be limited to items that have one or more refiner values. The managed properties that are enabled as refiners in the search schema are listed in the Choose your refinerssection. Select a refiner value in the list, and then select Add to add it to the query.
If you want search results to display as a group on one or more managed properties, select Show more. This is useful to display several variants for a given item, and want to group them under a single result.
SORTING tab
In this tab, you can specify how you want your search results to be sorted. The managed properties that are set as sortable in the search schema are listed in the Sort by drop-down list. From this list, select a managed property, and then select Descending or Ascending. To add more sorting levels, select Add sort level.
If you selected Rank from the Sort by list, you can select which ranking model to use for sorting in the Ranking Model list. You can also add more rules and conditions by selecting Add dynamic ordering rule.
SETTINGStab
Query rules
Select if to use query rules.
URL Rewriting
Select if you want the URL rewrite to the item details page to be relative for each catalog item as defined when you connected your publishing site to a catalog. If you select Don’t rewrite URLs, the URLs for catalog items will point directly to the library item of the connected catalog.
Loading behavior
Select when you want the search results returned by the CSWP to appear on the web page. If you use the default option, Sync option: Issue query from the server, queries are issued from the server, and the search results are included in the page response that SharePoint returns. If you selectAsync option: Issue query from the browser, the queries are issued from the user’s browser after the complete page is received. You can use this option for content such as Recommendations or Popular Items.
Priority
Select the priority for content that’s displayed by this Web Part in relation to other Search Web Parts. If SharePoint is running under a heavy load, the queries will be run according to their priority.
Caching
Select one Active Directory security group if you want search results to be cached for users in the group. By caching search results for a security group, you can reduce page load time.
NOTE    You should only select a security group where search results are identical for all users in the group. For more information, see this article.
TEST tab
In this tab, you can preview query details sent by the CSWP.
Query text
Shows the query that will be run by the CSWP.
Select Show more to display additional information.
Query template
Shows the content of the query template that is applied to the query.
Refined by
Shows the refiners applied to the query as defined on theREFINERS tab.
Grouped by
Shows search results that are grouped by managed property as defined in the REFINERS tab.
Applied query rules
Shows which query rules are applied to the query.
Query template variables
Shows the query variables that are applied to the query, and the values of these variables as they apply to the current page. To preview the results, select Test Query.
To test how the query works for different user segment terms, select Add user segment term. To preview the results, select Test Query.
Query text
Shows the query that will be issued by the CSWP.

Control how content is displayed in a Content Search Web Part

To control how content is displayed in a CSWP, you have to customize display templates.
Here are some examples of how content looks before and after applying a customized display template to a CSWP.
Before
After
Default display template
Customized display template
To learn how to create a custom display template, see SharePoint 2013 Design Manager display templates.

Add a Content Search Web Part

  1. Make sure that you’re a member of the Designers SharePoint group on the site where you want to add the Web Part.
  2. Go to the page where you want to add the Web Part.
  3. From Settings Small Settings gear that took the place of Site Settings., select Edit page.
  4. In the Zone where you want to add the Web Part, select Add a Web Part.
  5. In the Categories list, select Content Rollup.
  6. In the Parts list, select Content Search > Add.

About the Content Search Web Part

When visitors browse to a page that contains a CSWP, the Web Part automatically issues a query. The search results are displayed within the CSWP. In most cases, visitors won't even know that search technology is being used to display the content they're viewing. To them, it'll look and feel like any other webpage.
By configuring a query in a CSWP, you can define which content visitors will see when they browse to a page that contains a CSWP. By default, the query in the CSWP is configured to show the three most recently changed items on the site. By configuring the query, you can change the number of items that are shown in the CSWP and which content is shown. For example, you can configure the query so that the CSWP will show nine list items from a particular list, or the last six documents the visitor created in a document library.

No comments:

Post a Comment