solving sql server problems for millions of dbas and developers since 2006



SQL Server DBA Tips SQL Server Developer Tips SQL Server Business Intelligence Tips SQL Server Career Tips SQL Server Tip Categories SQL Server Tutorials SQL Server Webcasts SQL Server Whitepapers SQL Server Tools SQL Server Questions and Answers MSSQLTips Authors About MSSQLTips SQL Server User Groups MSSLQTips Giveaways MSSQLTips Advertising Options

MSSQLTips Facebook Page MSSQLTips LinkedIn Page MSSQLTips RSS Feed MSSQLTips Twitter Page MSSQLTips Google+ Page

SQL Product Highlight

Red Gate Software - SQL Monitor

SQL Server performance monitoring and alerting - SQL Monitor offers an easy entrance to advanced server monitoring with a simple design that's a refreshing change from the status quo. Red Gate have added custom metrics and user roles to the product without spoiling its ease-of-use, to help you answer that timeless question, 'How healthy are your servers?'

Learn more!








New DMF for SQL Server 2008 sys.dm_fts_parser to parse a string

By: | Read Comments | Print

Jugal has 8+ years of extensive SQL Server experience and has worked on SQL Server 2000, 2005, 2008 and 2008 R2.

Related Tips: More

Problem

Many times we want to split a string into an array and get a list of each word separately. The sys.dm_fts_parser function will help us in these cases. More over, this function will also differentiate the noise words and exact match words. The sys.dm_fts_parser can be also very powerful for debugging purposes. It can help you check how the word breaker and stemmer works for a given input for Full Text Search.

Solution

In SQL 2008 and forward, with Integrated Full Text Search (iFTS) we can now very easily split words in an array of strings with the help of the dynamic management function sys.dm_fts_parser. This function takes a full text query and breaks it up using the word breaker rules, applies stop lists and any configured thesaurus.

Permission Required
This requires membership of the sysadmin fixed server role and access rights to the specified stoplist.

Syntax
sys.dm_fts_parser('query_string', lcid, stoplist_id, accent_sensitivity)

Parameter Description

query_string

Query string that you want to parse. Query string can include logical operators,inflectional forms and thesaurus.

lcid

Locale identifier (LCID) of the word breaker

stoplist_id

stoplist_id accepts the Int value only. stoplist_id is used by the word breaker identified by lcid. If we specify NULL not stoplist will be used. If we specify 0 than the system STOPLIST will be used.

Stop List will be unique in the database, you can retrieve the full text index stop list using below query.

SELECT object_name(object_id), stoplist_id FROM sys.fulltext_indexes

accent_sensitivity

Accepts the Boolean value only, 0 is for Insensitive and 1 is for sensitive.


Examples

FORMSOF( THESAURUS, query_string)

You can check how the thesaurus expands or replaces all or part of the input using the below query

SELECT *   FROM sys.dm_fts_parser ('FORMSOF( THESAURUS, "Management Studio")', 2057, 0, 0)  
Output

In SQL 2008 and forward, with Integrated Full Text Search (iFTS) we can now very easily split words in an array of strings



FORMSOF( INFLECTIONAL, query_string)

To check how the word breaker and the stemmer parse a query term and its stemming forms, you can execute the below query.

SELECT  *  FROM sys.dm_fts_parser ('FORMSOF( INFLECTIONAL, "Operating System")', 2057, 0, 0)  

Output

the function takes a full text query and breaks it up using the word breaker rules, applies stop lists and any configured thesaurus



sys.dm_fts_parser('query_string', lcid, stoplist_id, accent_sensitivity)

This query will split the words in a string.

SELECT *  FROM sys.dm_fts_parser ('SQL or MySQL or Oracle or DB or technologies or the or dbservers', 1033, 0, 0)  

Output

check how the word breaker and the stemmer parse a query term and its stemming forms, you can execute the query

Next Steps

  • Use the special character in the query string and test the output
  • Use this function with a table using a Cross Apply join


Related Tips: More | Become a paid author


Last Update: 12/3/2010

Share: Share 






Comments and Feedback:


Post a Comment or Question

Keep it clean and stay on the subject or we may delete your comment.
Your email address is not published. Required fields are marked with an asterisk (*)

*Name   *Email   Notify for updates
Comments
*Enter Code refresh code


 
Sponsor Information
"Amazing, Amazing, Amazing! SQL doctor is truly one of the most powerful tools I have seen."

It takes just 5 minutes to connect your SQL Databases to source control. Got 5 minutes? Get started now.

Need SQL Server help and not sure where to turn? Reach out to the Edgewood consultants for a Health Check.

Find and Fix SQL issues with Foglight Performance Analysis. Get a free copy.

Join the over million SQL Server Professionals who get their issues resolved daily.

Valuable SQL Server web casts on Performance Tuning, Development, Administration, SSIS and more...


Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | about
authors | contribute | feedback | giveaways | user groups
Some names and products listed are the registered trademarks of their respective owners.


Edgewood Solutions LLC | MSSharePointTips.com | MSSQLTips.com