Understanding Full Text Search In Sql Server 2005

  • Uploaded by: Kashyap Patel
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Understanding Full Text Search In Sql Server 2005 as PDF for free.

More details

  • Words: 1,328
  • Pages: 4
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 along with 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 in SQL Server. Although the concept of full text search is not new in SQL Server 2005, there are considerable enhancements in performance and manageability of SQL Server 2005. In this article we will discuss the usage of full text search and the architecture of full text search in detail. We will also compare full text search 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 search functionality involved in User Interface (UI). The UI for the database is a website open to the internet so response time is crucial. Now if the administrator of the website wants to search all the customer names which have a specific pattern, then he or she queries the database system 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 actual requirement. 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 the

result. 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 run on unstructured text data with the support of search on different data types like formatted binary. Full text search qualifies all these and in fact has many advantages. Architecture

Let us identify different components of Full text search before going ahead with understanding the architecture. 

The Microsoft Full-Text Engine for SQL Server (MSFTESQL)



The Microsoft Full-Text Engine Filter Daemon (MSFTEFD) that comprises the following: 1. Filter 2. Protocol handler 3. Word breaker

MSFTESQL is a windows service that is a tightly integrated component of SQL Server 2005 which is used as a search engine. This is built on the (MSSearch) technology. MSFTESQL service is mainly involved in providing 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 servers

MSSearch is a process in windows system that is responsible for doing the cataloguing and indexing. This file name is mssearch.exe. This process will be used by MSFTESQL service to implement the indexing and full-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 the

database node in Management studio and click on the storage node. We can see the Full text catalog in this node. 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 the

full-text search functionality for a table. To do this we can select the respective table and select the right click 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 full text 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 full population 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. Or we 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 and schedule 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 the full-text search. There are four types of predicates used in SQL Server 2005 for running the Full text search queries. A predicate is an expression that evaluates to TRUE, FALSE or UNKNOWN. A predicate is used in a where condition in T-SQL statement. 1. FREETEXT 2. FREETEXTTABLE 3. CONTAINS 4. CONTAINSTABLE Let us see each one of them individually with its usage. FREETEXT Freetext is the simplest form of predicates in the full text search. It searches for the words that give the similar meaning and not the exact wording of the word. This kind of predicate is used where we go to query a document as a whole for a word in it. The freetext not only returns the exact wording, but also the nearest meanings attached to it. Listing 1 shows the usage of the free text. To understand listing 1, the user should have a basic understanding of T-SQL queries. Let us also see the usage of Freetext with a help of an example. 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 based on the string given as the predicate. Freetexttable is similar to freetext except the former can return tables and the latter one can return columns. Listing 4 shows the usage of Freetexttable.

Listing 5 FREETEXTTABLE (table , { column_name | (column_list) | * } , 'freetext_string' [ ,LANGUAGE language_term ] [ ,top_n_by_rank ] )

CONTAINS As the name suggests, Contains actually works by verifying if a word or phrase is contained in the columns. It can search for a word, prefix of a word, synonym of a word, word formed from another word. We need to specify the language in case the languages of the words are not of the same language. Listing 5 shows the simple usage of contains column. Listing 6 SELECT [Name], [Address] FROM Customer WHERE AGE > 30 AND CONTAINS([Name], 'abcde');

CONTAINSTABLE

Contains and Containstable are similar to freetext and freetexttable. The former one returns columns and the latter one returns the table. References

Conclusion Full-text search allows fast and flexible indexing for keyword-based query of text data stored in a Microsoft SQL Server 2005 database. There are many enhancements made to the full-text search. In sql server 2005 it uses the MSSearch functionality. The concept of ranking is also included in this version. Ranking can give a score about the relevance of the search made. In this article we tried to expose all the basic functionalities of full-text search.

Related Documents


More Documents from ""