Sign in

Configure a Content Search Web Part in SharePoint

Display content on your SharePoint pages by configuring simple and advanced queries in a Content Search Web Part.

Add a Content Search Web Part (CSWP) to your page

If you haven't inserted a Content Search Web Part on your page, follow these steps.:

  1. From Settings Small Settings gear that took the place of Site Settings., click Edit Page.

  2. Place your cursor in the area where you want the CSWP, click Insert on the ribbon, and then click Web Part.

    Insert Web Part ribbon menu inserting a CSWP
  3. From the Parts menu, click Content Rollup, click Content Search, and then click Add.

    The add button from the Insert Part menu
  4. You should see your new CSWP appear on the page, and you';re ready to set up the query.

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.

Configure a simple search on a CSWP
  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, click the Content Search Web Part Menu arrow, and then click Edit Web Part.

    Web Part Menu to select Edit Web Part
  5. Click Change query in the Search Criteria section under the Properties section, in the Web Part tool pane.

    The Change Query button in the CSWP properties window

    A dialog box as shown in the image below 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.

    The CSWP Select a query options menu

    Restrict results by app

    Select an option from the list to restrict results to a specific site, library, list, or URL.

    CSWP Restrict by app menu choices

    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 by current 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.

  6. Click OK.

The BASIC tab when configuring the query in a Content Search Web Part

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 the BASICS 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.

Note: If any of these features or tabs aren't available, contact your site administrator.

Configure an advanced query
  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:

  7. From The BASICS dialog:

    BASICS tab

    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.

  8. From the REFINERS dialog

    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 refiners section. 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.

  9. From the SORTING dialog

    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.

  10. From the SETTINGS dialog

    SETTINGS tab

    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 select Async 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.

  11. From the TEST dialog

    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 the REFINERS 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.

  12. Click OK.

Top of Page

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.

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.

Top of Page

See Also

Change settings for the Search Results Web Part



Was this information helpful?

How can we improve it?

How can we improve it?

To protect your privacy, please do not include contact information in your feedback. Review our privacy policy.

Thank you for your feedback!