UltimateSearchSL Tutorial
1. Running the sample solution
2. Creating your own solution
3. Adding controls to your page
4. Indexing your web application
5. Updating the Config file
6. Displaying search results
7. Renaming the Admin directory
8. Automatic indexing options
9. Indexing PDF, DOC, and more
10. Passing querystring parameters to the Admin page

1. Running the sample solution
1. Open C:\inetpub\wwwroot\Karamasoft\SL4.0\UltimateSearchSL\v1.0\Demos\UltimateSearchSample.sln in Visual Studio 2010.

2. Right-click UltimateSearchSampleSL.Web and select 'Set as StartUp Project'.

3. Right-click UltimateSearchSampleSLTestPage.aspx and select 'Set As Start Page'.

4. Hit F5 to run the solution.

5. Click 'Yes' when VS 2010 displays 'Do you want to enable Silverlight debugging for this project?'.

Back to Top
2. Creating your own solution
1. Run Visual Studio 2010 and click New Project.

2. Select Visual C# -> Silverlight under Installed Templates. If you don't see that you will need to install Silverlight 4 SDK for VS 2010.

3. Select Silverlight Application in the right pane. If you don't change the default project name and location it will create the SilverlightApplication1 project under C:\users\yourname\documents\visual studio 2010\Projects when you click Next.

4. Leave the default settings in the next dialog box to create the SilverlightApplication1.Web ASP.NET web application project under the same C:\users\yourname\documents\visual studio 2010\Projects\SilverlightApplication1 folder.

5. Copy the DLL files (except for UltimateSearchSampleSL.dll) from C:\inetpub\wwwroot\Karamasoft\SL4.0\UltimateSearchSL\v1.0\Demos\UltimateSearchSampleSL\Bin\Release to C:\users\yourname\documents\visual studio 2010\Projects\SilverlightApplication1\SilverlightApplication1\bin\Debug.

6. Copy the DLL files (except for UltimateSearchSampleSL.Web.dll) from C:\inetpub\wwwroot\Karamasoft\SL4.0\UltimateSearchSL\v1.0\Demos\UltimateSearchSampleSL.Web\Bin to C:\users\yourname\documents\visual studio 2010\Projects\SilverlightApplication1\SilverlightApplication1.Web\bin.

7. Copy the UltimateSearchInclude and UltimateSpellInclude directories from C:\inetpub\wwwroot\Karamasoft\SL4.0\UltimateSearchSL\v1.0\Demos\UltimateSearchSampleSL.Web to C:\users\yourname\documents\visual studio 2010\Projects\SilverlightApplication1\SilverlightApplication1.Web.

8. Give full permission to the local "NETWORK SERVICE" user (ASPNET user in Windows XP) on the Index and Log directories under the UltimateSearchInclude directory of your web application so that it can save index and log files properly. Open Windows Explorer, right-click "UltimateSearchInclude\Index" directory, select "Properties" and click the Security tab.
If you don't see the Security tab in Windows XP, open Windows Explorer, and choose Folder Options from the Tools menu. On the View tab, scroll to the bottom of the Advanced Settings, clear the check box next to "Use Simple File Sharing", click OK to apply the change, and you should now have a Security tab when viewing the properties of a file on an NTFS volume.
Select your machine in the "Look in" dropdown box. Click the "Add..." button. Add NETWORK SERVICE (ASPNET in Windows XP) by double-clicking on it and click OK. In the "Permissions" section, allow "Full Control" permissions and click OK.
Now follow the same steps on the Log directory.

9. Open the web.config file under your SilverlightApplication1.Web directory and add the following code to the <configuration> section (if it is not already there) to enable web service calls made by the UltimateSearchSL control:

    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    </system.serviceModel>

10. Right-click on SilverlightApplication1 in Solution Explorer in Visual Studio and select "Add Service Reference". Click on Discover button and then click on the Address dropdown and select "http://localhost:[port_number]/UltimateSearchInclude/SearchService.svc" and click Go button. Select SearchService in Services section. Change ServiceReference1 in Namespace textbox to SearchServiceReference and click OK. Do the same thing for Suggest and Admin services.

Back to Top
3. Adding controls to your page
1. While your MainPage.xaml page is open in Visual Studio by default, move your mouse onto the Toolbox tab on the left.

2. Right-click and select Choose Items.

3. Select the Silverlight Components tab, click Browse, and select C:\users\yourname\documents\visual studio 2010\Projects\SilverlightApplication1\SilverlightApplication1\bin\Debug\Karamasoft.Windows.Controls.UltimateSearchSL.dll and click Next.

4. Select only the UltimateSearchSLInput and UltimateSearchSLOutput controls and click OK.

5. Drag UltimateSearchSLInput from the toolbox and drop onto MainPage.xaml.

6. Drag UltimateSearchSLOutput from the toolbox and drop onto MainPage.xaml.

7. Build your solution.

Back to Top
4. Indexing your web application
1. Right-click SilverlightApplication1.Web/UltimateSearchInclude/Admin/UltimateSearchSL.admin.aspx in Solution Explorer and click 'View in Browser'.

2. Click 'Index Full' to index your web application manually on the Admin page. You may also index your application automatically. Indexing will be done based on your configuration settings in the Config file.

3. It will index all the ASPX and HTML pages under SilverlightApplication1.Web (e.g. SilverlightApplication1TestPage.aspx, SilverlightApplication1TestPage.html) by default. If you change the content of these pages and reindex your web application you will see the indexed content by clicking the 'Display Indexed Pages' and 'Display Indexed Words' on the Admin page.

4. Note that your Silverlight XAML pages won't be indexed as they are rendered only on the client-side. They are binary objects in the SilverlightApplication1TestPage.aspx and SilverlightApplication1TestPage.html pages, and cannot be indexed on the server-side.

5. Close the Admin page and hit F5 in Visual Studio to run your solution.

6. Enter a word in the search box and click the search button to see the search results based on your indexed content.

Back to Top
5. Updating the Config file
UltimateSearchSL.config file under the UltimateSearchInclude directory of your web application lets you configure all the parameters to customize the indexing process. You can specify which directories to scan and index, what type of documents to index, how to score keywords based on their positions, and much more. You can update the Config file in Visual Studio, Notepad, or any other editor of your choice. It has an XML format just like the Web.config file.

Read the Config document to learn more about these settings.

Back to Top
6. Displaying search results
As a common practice you should have the UltimateSearchSLInput control on all pages either inside a user control, or inside a header include file so that the user can make a search from all pages in your website. However, you would normally have only one page to display the search results, and you should have an UltimateSearchSLOutput control on that page only. To display the search results on this particular page regardless of where the search is submitted from, you should set the SearchOutputPage property of the UltimateSearchSLInput control to the url of the search results page that has the UltimateSearchSLOutput control on it.

Back to Top
7. Renaming the Admin directory
If you have a public website it would be a good idea to rename YourApplication\UltimateSearchInclude\Admin directory such as YourHiddenAdmin so that only the administrative personnel can open this page.

Back to Top
8. Automatic indexing options
You can automatically index your web application in one of the following ways:

1. Windows Scheduled Task: If you want to index your website at specified times, you can create a Windows scheduled task. Go to Control Panel -> Administrative Tools -> Task Scheduler (or Scheduled Tasks based Windows OS) and select Create Basic Task (or Add New Task based Windows OS). Enter task name and specify trigger and schedule. Set the program to run as below. Note that you need to have SilverlightApplication1.Web set up as a web application on IIS:

"C:\Program Files\Internet Explorer\iexplore.exe" http://localhost/SilverlightApplication1.Web/UltimateSearchInclude/Admin/UltimateSearchSL.admin.aspx?cmd=IndexFull

It will open an Internet Explorer browser window, open the Admin page and pass a querystring parameter such as "IndexFull" in order run full indexing. You can change the querystring parameter based on your needs. Check out the querystring parameters that you can pass into the Admin page.

2. UltimateSearchService API: If you want to index your website programmatically from inside your web application, you can call the public methods (IndexFull, IndexIncremental, etc.) of UltimateSearchService. Check out the WCF Service API document to learn more.

Back to Top
9. Indexing PDF, DOC, and more
If you want to index documents such as PDF, DOC, PPT, and so on, you can add those file extensions to the "includeFileTypeList" in the Config file. UltimateSearchSL reads Microsoft Office documents with the help of the Ifilters that already exist on Windows machines. UltimateSearchSL has a built-in parser to read the PDF files. However, if you experience any issues with it and want to use Adobe IFilter, you can download it from Adobe website, install it on your machine and set the "useIfilterToParsePdf" flag to "true" in the Config file.

Back to Top
10. Passing querystring parameters to the Admin page
You can set the querystring parameter "cmd" to one of the following values in order to run indexing without having to click a button on the Admin page:

   IndexFull, IndexIncremental, StopIndexing, CancelIndexing, LoadCopiedIndex, DeleteIndex, DisplayIndexedPages, DisplayIndexedWords

For example:

   http://localhost/Karamasoft/SL4.0/UltimateSearchSL/v1.0/Demos/CS/UltimateSearchInclude/Admin/UltimateSearchSL.admin.aspx?cmd=IndexFull

Read the Admin document to learn more about these commands.

Back to Top