• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Understanding Full Text Search in SQL Server 2005
Abstract
This article exposes the concept of Full text search. It also explains the architecture of full-text search indexing alongwith the enhancements made to it in SQL Server 2005.
Introduction
Full text search is the search functionality that enables a fast and easy way of 
searching
text based data inSQL
Server
. Although the concept of full text search is not new in SQL Server 2005, there are considerableenhancements in performance and manageability of SQL Server 2005. In this article we will discuss theusage of full text search and the architecture of full text search in detail. We will also compare full textsearch with other
search options
 "Like" and discuss the reason for the superior functionality set of full-text search.
Why Full Text Search?
Let us assume that we have huge amounts of data in the database and we are having some searchfunctionality involved in User 
 (UI). The UI for the database is a 
 open to the internet soresponse time is crucial. Now if the administrator of the website wants to search all the customer nameswhich have a specific pattern, then he or she queries the database 
 as shown in Listing 1.
Listing 1
SELECT [NAME] FROM [CUSTOMER] WHERE [NAME] LIKE '%PATTERN%'
The query in Listing 1 is fine for getting the result. But in real time this may not suffice the actualrequirement. Let us see why the query in Listing 1 may not yield us actual results.
 
In case of a large amount of data, the like query works very slowly. It may take minutes to return theresult. This is true especially for unstructured text data.
 
If I want to query my data on formatted binary data [format], I cannot use a Like query.So to summarize, the need to of the hour is for a search functionality that is fast, efficient and can also be runon unstructured text data with the support of search on different data types like formatted binary. Full textsearch qualifies all these and in fact has many advantages.Architecture
 
Let us identify different components of Full text search before going ahead with understanding thearchitecture.
 
The
Microsoft
Full-Text Engine for SQL Server (MSFTESQL)
 
The Microsoft Full-Text Engine Filter Daemon (MSFTEFD) that comprises the following:1.
 
Filter2.
 
Protocol handler3.
 
Word breakerMSFTESQL is a windows service that is a tightly integrated component of SQL Server 2005 which is usedas a search engine. This is built on the (MSSearch) technology. MSFTESQL service is mainly involved inproviding three functionalities.
 
Implementing full-text catalogs and indexes for database
 
Querying the database with words, phrases and words in close proximity [meaning of a word]
 
Managing the full-text catalogs that are stored in SQL serversMSSearch is a process in windows system that is responsible for doing the cataloguing and indexing. Thisfile name is mssearch.exe. This process will be used by MSFTESQL service to implement the indexing andfull-text catalogs.
Implementing Full Text search
Let us discuss the steps for implementing full-text search in SQL Server 2005.
 
Adding a full text search catalog to the database
 – 
To add a full text search catalog we need to open thedatabase node in Management studio and click on the storage node. We can see the Full text catalog in thisnode. We have an option for adding the full-text catalog by which we can add a new catalog.
 
Adding the Full text indexing table
 – 
We need to specify to the database that we want to implement thefull-text search functionality for a table. To do this we can select the respective table and select the rightclick option of Full-Text Index and Define Full-Text index. This opens up the Full text indexing wizard.1.
 
Using the Full text indexing wizard we select a unique index.2.
 
Once we select a unique index and move to the next step, we select the columns that are eligible for fulltext queries. This enables the full-text search for the selected columns.3.
 
We need to select the option of how can we track the changes. If automatically selected then a fullpopulation of indexing occurs. To avoid a population at the end of this wizard, select the Do Not Track Changes option, and clear the Start Full Population When Index Is Created checkbox.
 
4.
 
Once we are done with step 3 we need to map the catalog out of all the catalogs at the database level. Orwe could even create a new catalog for the full text search.5.
 
This is the last step of the wizard. Here we can create a table schedule and catalog schedules andschedule them with time. A table schedule can have a name, time of schedule and occurrences.Once we create them and click on the finish button the full-text index is created.
Running the Full Text search
Until now, we have set-up the full text search catalogues and indexes. Let us run the some queries for thefull-text search. There are four types of predicates used in SQL Server 2005 for running the Full text searchqueries. A predicate is an expression that evaluates to TRUE, FALSE or UNKNOWN. A predicate is used ina where condition in T-SQL statement.1.
 
FREETEXT2.
 
FREETEXTTABLE3.
 
CONTAINS4.
 
CONTAINSTABLELet us see each one of them individually with its usage.FREETEXTFreetext is the simplest form of predicates in the full text search. It searches for the words that give thesimilar meaning and not the exact wording of the word. This kind of predicate is used where we go to querya
document
as a whole for a word in it. The freetext not only returns the exact wording, but also the nearestmeanings attached to it. Listing 1 shows the usage of the free text. To understand listing 1, the user shouldhave a basic understanding of T-SQL queries. Let us also see the usage of Freetext with a help of anexample. Listing 2 gives an example for the usage of FREETEXT.
Listing 2
FREETEXT ( { column_name | (column_list) | * }, 'freetext_string' [ , LANGUAGE language_term ] )
 
Listing 3
SELECT CellularPhone FROM CART WHERE FREETEXT (CellularPhone, '2222')
 
Listing 4
SELECT CELLULARPHONE FROM CART WHERE CELLULARPHONE LIKE '%2222%'
 
FREETEXTTABLE
Freetexttable returns a collection of one or more rows as a table. The columns in the rows are selected basedon the string given as the predicate. Freetexttable is similar to freetext except the former can return tablesand the latter one can return columns. Listing 4 shows the usage of Freetexttable.
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...