Developing the Search page
Kentico allows users to perform index-based searches through all document content, as well as other types of data. The following instructions describe how to add a basic search page to your website.
Configuring search fields for the Computer document type
First, set up the search options for the Computer document type that you created for the Products section.
- Open the Document types application.
- Edit () the Computer document type.
- Switch to the Search fields tab.
- Select the Search is enabled check box.
- Set the Image field to ComputerImage.
- Click Save.
Product documents are now searchable.
Creating a smart search index
Before you can use the search, you need to add a smart search index covering the website’s documents.
- Open the Smart search application.
- Click New index.
- Fill in the following details for the search index:
- Display name: My website - Documents
- Index type: Documents
- Analyzer type: Standard
- Stop words: (default)
- Click Save. The index’s editing interface opens.
- Open the Indexed content tab and click Add allowed content.
- Type /% into the Path field and click Save. This ensures that the index includes all documents on the website.
- Switch to the Sites tab and assign the index to My website.
- Switch to the Cultures tab and choose the default culture of your site (typically English - United States).
- Open the General tab and click Rebuild.
Once the system rebuilds the index, you can start using it on the website. The Index info section displays the current status of the index and other relevant information.
Adding the search page
- Open the Pages application.
- Select the root of the content tree (My website).
- Click New ().
- Choose the Page (menu item) document type.
- Type Search as the Page name and choose the Use existing page template option. Select the General category and the Search template.
- Click Save to create the page.
- Click and drag the Search page to the end of the document list.
- Switch to the Design tab and Configure (double-click) the SearchDialogWithResults web part.
- Click Select next to the Indexes property and choose the My website - Documents search index created in the previous section.
- Click OK.
To try out the search functionality, view the /Search page in Preview mode. Type PC into the Search for box and click Search.
When you click a search result, the system redirects you to the corresponding page.
Modifying the format of the search results
If you prefer a different design of the search results, you can modify the format by editing the SmartSearchResults (or SmartSearchResultsWithImages) transformation in Document types -> Root -> Transformations.