In this tutorial, you will learn a few techniques that will allow you to perform a simple search within Umbraco 8. Out-of-the-box, Umbraco uses the Lucene search index. Every-time you save or modify a page within Umbraco the search index is updated. You can find the search indexes within the App_data folder within the webroot.
Umbraco provides its own API layer that sits on top of Lucene called Examine. When searching for pages within Umbraco you will be interfacing with the Examine APIs.
To perform a search you will need to get access an indexer. The default Umbraco index is called 'ExternalIndex' this is the index you can talk to in order to get page information. If you used Umbraco 7 or below, you may notice that in Umbraco v8 the ExamineSettings.config which used to live within the 'config' folder, does longer exists. The focus of this article is to perform a search using the default index 'ExternalIndex'. For reference, if you want to create your own custom index, you will need to create a custom component.
To get access to the index, you will need to use this code:
To do a simple search against everything in the index you can do:
If you wanted to only search for pages filter by a certain document type, you can do this:
To add sorting by a certain field, you can do this: