Step 4: Test the Sitecore.Search File Crawler
Now that you have created a Sitecore.Search Crawler and a class that displays your results it is time to test what you have created.
There are two simple tests that you can perform.
Test Scenario 1
1. Compile your Sitecore.Search Crawler solution.
2. Open Sitecore and rebuild the search index.
To rebuild the search index: In the Sitecore Desktop open the Control Panel, click Database and then click Rebuild the Search Index.
In the Select Search Index dialog box select Quick search index, then click Rebuild.
3. In the Sitecore Desktop, enter part of the file name in the search box – the system will show matching file names and allow you to open the files in the editor.
Search results found:
Test Scenario 2
1. Enter some text into a file ASPX layout, ASCX sublayout, XSL, CSS, JS or CS file. This could be a comment in the source code that describes certain functionality or a “TO DO” marker left for later. Quick search will look for this term.
2. Rebuild the search index (see Test Scenario 1).
3. Type the same or a similar term into the Quick search box. The system will display the name of the file and allow you to open it in the developer center.
- Test Scenario 1 before and after implementing the Sitecore.Search Crawler for the File System:
- Quick Search results using the search term sample in the Quick Search box.
The same search results after implementing the Sitecore.Search crawler for the file system return more files from the Web site root including XML and .ascx files under the Other category.
Extending the Sitecore.Search Crawler
The example of a Sitecore.Search Crawler described in this blog has been designed to demonstrate how it is possible to create you own crawler and therefore has been kept as simple as possible.
Once you have created a Sitecore.Search Crawler there are many ways in which you could extend and improve its functionality.
For example:
- Extend the class to monitor and update search indexes automatically if a file changes.
- Exclude certain files or items from search results
- Conduct filtering at the time of crawling
- Add metadata and custom fields to search by. For example, author, size, age etc.
Some of these topics may be covered in my future blog posts.
The full solution for the File Crawler is also available as a Sitecore Shared Source Module.
Click here to download the module:
File Crawler Shared Source Module
To lean how to view the contents of an index read Jens Mikkelsen’s blog post on the Sitecore Lucene Index Viewer.