Walkthrough: Adding search functionality to your page

Abstract

How to use and configure search in SXA.

To enable visitors to quickly find what they are looking for, SXA comes with flexible out-of-the-box search functionality. There are different search renderings available from the Toolbox, for example, renderings that add a search box, renderings that sort or filter the search results, and so on. This makes it easy to set up a simple search solution for your site.

For example, you can add a basic search solution to your page that contains a search query box and lists the results with pagination.

This walkthrough describes how to:

For users to view the results of their search, you must add the Search Results rendering on the page. For simple solutions, you can have the search results appear on the same page.

To add the Search Results rendering:

  1. To add a search results section to your page, from the Toolbox, drag the Search Results rendering to the page.

  2. To change the text of the search box on the page, in the Search Results toolbar, click Edit component configuration itemA0173FD240754803B4109340ECAC8288.png and enter the text that you want to appear when the search returns no results. Click OK.

    924384955E9F46C3B9F350F7CC3A93F8.png
  3. To change the Search Results rendering parameters, for example, to determine how many results should be loaded at once, or how the results are sorted, in the Select the Associated Content dialog box, select the Default item.

  4. In the Control Properties dialog box, edit the following fields to specify how to arrange the search results:

    • Search results signature – enter the unique signature of a specific Search Results rendering to limit the search results. This can be convenient when you have more than one search result rendering on the page and you only want to filter on specific search results. When you leave this field empty, it will filter all Search Results renderings with no signature.

    • Search scope – select a scope to limit the search results.

    • Page size – enter the number of results you want to be loaded by the rendering.

    • Default language filtering – select the language you want to use for the search.

    • Default sort order – select the way the results are sorted on the page. This is only used when the Sort Results rendering is not used.

With the Page Selector rendering, you can determine how to display the results pages. The number of pages displayed depends on the default page size configured in the Search Results rendering or, if the Page Size rendering is used, on the page size configured in the Page Size rendering.

To add the Page Selector rendering:

  1. From the Toolbox, drag the Page Selector rendering to the page.

  2. In the Page Selector toolbar, click Edit component configuration item3B70AE229C1F4D60A83A3905D0EC89AD.png .

  3. In the dialog box, fill in the fields and click OK.

    For example, the following fields:

    29300FA9D01F4E1C865B7E171E860668.png

    Appear as:

    8AC80E53B5974F8AA3798CA2ADB94FDB.png
  4. To change the properties of the Page Selector rendering, for example, to determine how many pages are displayed in buttons, in the SearchBox, click More, and click Editcomponentproperties.

  5. In the Control Properties dialog box, edit the following fields and then click OK:

    • Search results signature – if you want to filter on specific Search Results renderings, enter the signature(s) (separated by a comma) of the Search Results rendering(s) that you want to search on.

    • Collapsed mode threshold – if you expect results on many pages, you can replace some of these pages by dots.

    For example, if you enter 10 in the Collapsed mode threshold field:

A150927EFEBD466BBC102CAE2D60C902.png

The following is displayed for the search results:

3EB3735B8D044610B9FC967EB6E7C735.png