Qondio
Front
Intel
IntelMart
Shares
My Qondio
Account
oyen > Intel > Full Text Search Tutorial

qondio.com/aeg0 PRINT EMAIL

Full Text Search Tutorial

Author Unknown

**Refer to Full Text Search Stey by Step Tutorial to view this tutorial with images that will guide you better.

Download and Install AdventureWorks for SQL Server 2008

Download AdventureWorks database: AdventureWorksDB.msi in Codeplex

Then double click your .msi file to Install your database.

By default it will install your database in
C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data

Your database will not appear automatically in your Object Explorer.

Go to Databases, right click then choose Attach...


If your database does not appear yet, refresh your Databases folder in the Object Explorer of your SQL Server Management Studio. To view your Object Explorer go to your menu bar then go to Views/Object Explorer or press F8.

Then you will see among your databases AdventureWorksDW.

Enable Full Text Search in Database

Create a new Full Text Catalog

A window will pop up to prompt for more details:
Full Text Catalog Name: FTCatalog

Create a new Full Text Index

Install Full Text Search
If your option is blocked (if it is not clickable) then re-run your SQL Server 2008 Installer. Under Installation (below Planning, on the left panel), choose New SQL Server stand-alone isntallation or add features to an existing installation.

Install Support Files.

Under Installation Type, choose Add features to an existing instance of SQL Server 2008.

Under Feature Selection check Full-Text Search.

Click Next then complete the installation. This will take around 5 minutes.

A Wizard window will appear after choosing Define Full-Text Index...

Follow the directions of the Wizard: choose the Primary Key for Indexing, then select all tables to enable full-text queries on all of them. Then choose the FTCatalog that we created previously when prompted. Skip Define population schedules for this tutorial. Then hit Finish.

Populate Index


Query Scripts - Test Full Text Search

Let's test our Full Text Search through the following SQL scripts:


On the new Query window, copy and paste the following scripts:

USE AdventureWorks
GO

SELECT EmployeeID, Title
FROM HumanResources.Employee
WHERE FREETEXT(*, 'Marketing Assistant');

SELECT EmployeeID, Title
FROM HumanResources.Employee
WHERE CONTAINS(Title, 'Marketing OR Assistant');

SELECT EmployeeID, Title
FROM HumanResources.Employee
WHERE CONTAINS(Title, 'Marketing AND Assistant');
GO

Then Execute or F5 to run the query.


Notice that the results of the first SELECT query and the second SELECT query are the same.

SELECT EmployeeID, Title
FROM HumanResources.Employee
WHERE FREETEXT(*, 'Marketing Assistant');

SELECT EmployeeID, Title
FROM HumanResources.Employee
WHERE CONTAINS(Title, 'Marketing OR Assistant');
The FREETEXT( ) query searches all job titles with either the string "Marketing" or "Assistant". The results are arranged according to their foreign keys.

By using the "AND" constraint on the third SELECT, only job titles with exact matches as the query string showed.

SELECT EmployeeID, Title
FROM HumanResources.Employee
WHERE CONTAINS(Title, 'Marketing AND Assistant');

The arrangement of the results still depend on the foreign key (EmployeeID).

FREETEXT( ) Is predicate used to search columns containing character-based data types. It will not match the exact word, but the meaning of the words in the search condition. When FREETEXT is used, the full-text query engine internally performs the following actions on the freetext_string, assigns each term a weight, and then finds the matches.

* Separates the string into individual words based on word boundaries (word-breaking).
* Generates inflectional forms of the words (stemming).
* Identifies a list of expansions or replacements for the terms based on matches in the thesaurus.

CONTAINS( ) is similar to the Freetext but with the difference that it takes one keyword to match with the records, and if we want to combine other words as well in the search then we need to provide the “and” or “or” in search else it will throw an error.


Contributor's Note

Refer to [url=http://beingoyen.blogspot.com/2008/09/full-text-search-step-by-step-tutorial.html]Full Text Search Stey by Step Tutorial[/url] to view this tutorial with images that will guide you better.

This intel first appeared on: http://beingoyen.blogspot.com/2008/09/full-text-search-step-by-step...

External Links

SQL Authority

Contributed by oyen on October 17, 2008, at 4:20 PM UTC.

PLEASE VISIT THE CONTRIBUTOR'S WEBSITE
Being (me): Pinay Programmer
SQL Server 2008 Tips and Tricks
beingoyen.blogspot.com

Reactions

No reactions yet.

Rate This Intel

Please login or sign up to rate this intel.

Comments

Please login or sign up to add a comment.

Share

Copyright Notice

The copyright for this content entitled "Full Text Search Tutorial" has been specified by the contributor as:

All Rights Reserved

This content may not be copied, distributed or adapted by anyone under any circumstances.

Login Here with
Any Email Address
Any Password
No account? Sign up.

Intel Contributor
This intel was contributed by oyen


Qondio Archive
May, 2012
123456
78910111213
14151617181920
21222324252627
28293031


2008
January, February, March, April, May, June, July, August, September, October, November, December
2009
January, February, March, April, May, June, July, August, September, October, November, December
2010
January, February, March, April, May, June, July, August, September, October, November, December
2011
January, February, March, April, May, June, July, August, September, October, November, December
2012
January, February, March, April, May

Sign Up
Not a member yet? Qondio is a powerful network for making it online. If you have a website to promote, we can help. Sign up and get in on the action.

About Qondio
Welcome to Qondio! Discover the awesome power this network can deliver by going to our About page. Or you could skip straight to the Sign Up form.

ABOUT
SUCCESS GUIDE
FEATURES
FAQ
ADVERTISE
CONTACT
USAGE POLICY
PRIVACY POLICY


TWITTER
FACEBOOK