HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket


If you selected the **Episerver Find** option while installing CMS, you can skip this step.

In the [previous step](🔗), you prepared the site for Optimizely Search & Navigation, but the CMS still uses Optimizely Search. In this step, you plug in Optimizely Search & Navigation and add basic free text search. Search features are based on the [Client class](🔗) and the `IClient` interface, which manage operations like indexing objects, getting documents, deleting documents, and searching. You can also use [Unified Search](🔗), which lets you index and query objects of existing classes.

## Search page type

In this example, you use the sample site, which already has a `SearchPage` (MVC). In Visual Studio, you can find the `SearchPage` page type in the sample site project, under **Models/Pages**. If your site does not have a search page, you need to [create one](🔗).

## Create a view and a controller for the search page

Here, you implement a basic, free-text search based on Unified Search. First, create a view model for the Optimizely Search & Navigation search, inheriting from the `PageViewModel`, and using `UnifiedSearchResults` for returning search hits objects with selected properties such as title and URL. The view model can look something like this:

Next, create a default page controller for the search page, which overrides the current one (which uses the built-in search) and uses `SearchClient` for the actual search.

Finally, create the view (using the new view model), which renders search results based on data sent from the controller. In this example, the view uses the layout provided in the sample site. You add a search box and a search button. The search page displays the entered query, the number of retrieved results, and the results. The view looks something like this:

Rebuild your project and verify that you can perform a free text search using Optimizely Search & Navigation on your website.


By default, only 10 search results appear on a page. To change this value, use the [**Take** method](🔗).