Readme_Item Finder Sample

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005.

The ItemFinder sample demonstrates how to implement search capabilities in database applications. By using the AdventureWorks2008R2 sample database and the Full-Text Search capabilities of SQL Server, ItemFinder enables users to search through resumes and product descriptions stored as XML. They can also search documents stored as binary large objects (BLOBs). This sample application demonstrates:

  • Advanced techniques, such as paging and caching.
  • New features in Full-Text Search, such as enhanced multilingual capabilities and the implementation of XML data type.

Default location: C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Full Text Search

Languages

Transact-SQL

Features

Prerequisites

Before running this sample, make sure that the following software is installed:

  • SQL Server
  • AdventureWorks2008R2 database that is available at the Microsoft.

Building the Sample

If you have not already created a strong name key file, generate the key file using the following instructions.

To generate a strong name key file

  1. Open a Microsoft Visual Studio 2005 command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.

    -- or --

    Open a Microsoft .NET Framework command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.

  2. Use the change directory command (CD) to change the current directory of the command prompt window to the folder where the samples are installed.

    Note

    To determine the folder where samples are located, click the Start button, point to All Programs, point to Microsoft SQL Server, point to Documentation and Tutorials, and then click Samples Directory. If the default installation location was used, the samples are located in <system_drive>:\Program Files\Microsoft SQL Server\100\Samples.

  3. At the command prompt, run the following command to generate the key file:

    sn -k SampleKey.snk

    Important

    For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.

To build the sample, in SQL Server Management Studio, load and execute the Scripts\install.sql script to set up full-text indexes and create the following stored procedures:

  • usp_SearchResumes
  • usp_SearchProducts
  • usp_SearchDocuments
  • usp_AddDocument

Build the application by using Microsoft Visual Studio 2005 or type the following in a .NET Framework command Prompt window:

msbuild /nologo /verbosity:quiet /property:Configuration=Debug CS\ItemFinder.sln

Running the Sample

To run the sample, run bin\Release\ItemFinder.exe (or bin\Debug\ItemFinder.exe).

Comments

The ItemFinder sample application provides a user interface that enables you to search resumes, product descriptions, and documents. You will also be able to use the sample to add documents to the Document table.

Sample data is available in many languages and formats. Through a set of drop-down lists, you can select the following:

  • A library (resumes, products, or documents).
  • A language (any language supported by Full-Text Search).
  • The maximum number of results.
  • The search type (CONTAINS or FREETEXT).

Use ItemFinder for the following tasks.

Choose a Search Condition

Enter the search condition in the text box, and click Go to execute the query.

If you select the search type CONTAINS, ItemFinder uses the contains_search_condition syntax. For example, you can search for "rear reflector" using the proximity operator NEAR by typing in the text box: "rear" NEAR "reflector". Whatever the contains_search_condition you use, make sure that the search text you type is enclosed in double quotation marks ("search text"). For more information, see CONTAINS (Transact-SQL).

Similarly, if you select the search type FREETEXT, ItemFinder uses the freetext_search_condition syntax. For example, if you use the "rear reflector" search condition, type into the text box: rear reflector. However, unlike CONTAINS, you do not enclose the search text in double quotation marks. For more information, see FREETEXT (Transact-SQL).

Browse Large Search Results

If the search results cannot fit a single page of the ListView element, only the first page of results is displayed. A simple, efficient in-memory cache stores the key and rank values that matched the search criteria and any data that has already been retrieved.

To scroll back and forth through the pages of results, use the Last and Next buttons.

To clear the cache, click Clear Results, perform a new search, or close the application.

Change the Host Name of the Database Server

The host name of the database server that will be used is stored in the App.config file.

To change the host name:

  1. Click Edit, and then click Database Settings.
  2. Edit the App.config file directly.

Add Supported Document Types to the Document Table

To add document types, click File, and then click Add New File.

In addition, you can use the Add New File menu for the following tasks:

  • Specify a name for a file.
  • Place a file in the file system.
  • Specify the file type.
  • Store a short description of the file.

Get Help on the Sample

To obtain information about the sample, click the Help menu and select About.

See Also

Other Resources

CREATE FULLTEXT CATALOG (Transact-SQL)
ALTER FULLTEXT CATALOG (Transact-SQL)
DROP FULLTEXT CATALOG (Transact-SQL)
CREATE FULLTEXT INDEX (Transact-SQL)
ALTER FULLTEXT INDEX (Transact-SQL)
DROP FULLTEXT INDEX (Transact-SQL)
CONTAINS (Transact-SQL)
CONTAINSTABLE (Transact-SQL)
FREETEXT (Transact-SQL)
FREETEXTTABLE (Transact-SQL)

Help and Information

Getting SQL Server 2008 R2 Assistance