sys.dm_fts_parser (Transact-SQL)

sys.dm_fts_parser (Transact-SQL)


Updated: June 10, 2016

THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

Returns the final tokenization result after applying a given word breaker, thesaurus, and stoplist combination to a query string input. The tokenization result is equivalent to the output of the Full-Text Engine for the specified query string.

sys.dm_fts_parser is a dynamic management function.

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

The query that you want to parse. query_string can be a string chain that CONTAINS syntax support. For example, you can include inflectional forms, a thesaurus, and logical operators.

Locale identifier (LCID) of the word breaker to be used for parsing query_string.

ID of the stoplist, if any, to be used by the word breaker identified by lcid. stoplist_id is int. If you specify 'NULL', no stoplist is used. If you specify 0, the system STOPLIST is used.

A stoplist ID is unique within a database. To obtain the stoplist ID for a full-text index on a given table use the sys.fulltext_indexes catalog view.

Boolean value that controls whether full-text search is sensitive or insensitive to diacritics. accent_sensitivity is bit, with one of the following values:

ValueAccent sensitivity is…

Words such as "café" and "cafe" are treated identically.

Words such as "café" and "cafe" are treated differently.
System_CAPS_ICON_note.jpg Note

To view the current setting of this value for a full-text catalog, run the following Transact-SQL statement: SELECT fulltextcatalogproperty('catalog_name', 'AccentSensitivity');.

Column nameData typeDescription
keywordvarbinary(128)The hexadecimal representation of a given keyword returned by a word breaker. This representation is used to store the keyword in the full-text index. This value is not human-readable, but it is useful for relating a given keyword to output returned by other dynamic management views that return the content of a full-text index, such as sys.dm_fts_index_keywords and sys.dm_fts_index_keywords_by_document.

 Note: OxFF represents the special character that indicates the end of a file or dataset.
group_idintContain an integer value that is useful for differentiating the logical group from which a given term was generated. For example, 'Server AND DB OR FORMSOF(THESAURUS, DB)"' produces the following group_id values in English:

1: Server
2: DB
3: DB
phrase_idintContains an integer value that is useful for differentiating the cases in which alternative forms of compound words, such as full-text, are issued by the word breaker. Sometimes, with presence of compound words ('multi-million'), alternative forms are issued by the word breaker. These alternative forms (phrases) need to be differentiated sometimes.

For example, 'multi-million' produces the following phrase_id values in English:

1 for multi
1 for million
2 for multimillion
occurrenceintIndicates the order of each term in the parsing result. For example, for the phrase "SQL Server query processor" occurrence would contain the following occurrence values for the terms in the phrase, in English:

1 for SQL
2 for Server
3 for query
4 for processor
special_termnvarchar(4000)Contains information about the characteristics of the term that is being issued by the word breaker, one of:

Exact match

Noise word

End of Sentence

End of paragraph

End of Chapter
display_termnvarchar(4000)Contains the human-readable form of the keyword. As with the functions designed to access the content of the full-text index, this displayed term might not be identical to the original term due to the denormalization limitation. However, it should be precise enough to help you identify it from the original input.
expansion_typeintContains information about the nature of the expansion of a given term, one of:

0 =Single word case

2=Inflectional expansion

4=Thesaurus expansion/replacement

For example, consider a case in which the thesaurus defines run as an expansion of jog:





The term FORMSOF (FREETEXT, run) generates the following output:

 run with expansion_type=0

 runs with expansion_type=2

 running with expansion_type=2

 ran with expansion_type=2

 jog with expansion_type=4
source_termnvarchar(4000)The term or phrase from which a given term was generated or parsed. For example, a query on the '"word breakers" AND stemmers' produces the following source_term values in English:

 word breakers for the display_termword
word breakers for the display_termbreakers
stemmers for the display_termstemmers

sys.dm_fts_parser supports the syntax and features of full-text predicates, such as CONTAINS and FREETEXT, and functions, such as CONTAINSTABLE and FREETEXTTABLE.

When you parse a query string, sys.dm_fts_parser uses the collation of the database to which you are connected, unless you specify the query string as Unicode. Therefore, for a non-Unicode string that contains special characters, such as ü or ç, the output might be unexpected, depending on the collation of the database. To process a query string independently of the database collation, prefix the string with N, that is, N'query_string'.

For more information, see "C. Displaying the Output of a String that Contains Special Characters," later in this topic.

sys.dm_fts_parser can be very powerful for debugging purposes. Some major usage scenarios include:

  • To understand how a given word breaker treats a given input

    When a query returns unexpected results, a likely cause is the way that the word breaker is parsing and breaking the data. By using sys.dm_fts_parser, you discover the result that a word breaker passes to the full-text index. In addition, you can see which terms are stopwords, which are not searched in the full-text index. Whether a term is a stopword for a given language depends on whether it is in the stoplist specified by the stoplist_id value that is declared in the function.

    Note as well the accent sensitivity flag, which will allow the user to see how the word breaker will parse the input having in mind its accent sensitivity information.

  • To understand how the stemmer works on a given input

    You can find out how the word breaker and the stemmer parse a query term and its stemming forms, by specifying a CONTAINS or CONTAINSTABLE query containing the following FORMSOF clause:

    FORMSOF( INFLECTIONAL, query_term )  

    The results tell you what terms are being passed to the full-text index.

  • To understand how the thesaurus expands or replaces all or part of the input

    You can also specify:

    FORMSOF( THESAURUS, query_term )  

    The results of this query show how the word breaker and thesaurus interact for the query term. you can see the expansion or replacements from the thesaurus and identify the resulting query that is actually being issued against the full-text index.

    Note that if the user issues:

    FORMSOF( FREETEXT, query_term )  

    The inflectional and Thesaurus capabilities will take place automatically.

In addition to the preceding usage scenarios, sys.dm_fts_parser can help significantly to understand and troubleshoot many other issues with full-text query.

Requires membership in the sysadmin fixed server role and access rights to the specified stoplist.

A. Displaying the output of a given word breaker for a keyword or phrase

The following example returns the output from using the English word breaker, whose LCID is 1033, and no stoplist on the following query string:

The Microsoft business analysis

Accent sensitivity is disabled.

SELECT * FROM sys.dm_fts_parser (' "The Microsoft business analysis" ', 1033, 0, 0);  

B. Displaying the output of a given word breaker in the context of stoplist filtering

The following example returns the output from using the English word breaker, whose LCID is 1033, and an English stoplist, whose ID is 77, on the following query string:

"The Microsoft business analysis" OR "MS revenue"

Accent sensitivity is disabled.

SELECT * FROM sys.dm_fts_parser (' "The Microsoft business analysis"  OR " MS revenue" ', 1033, 77, 0);  

C. Displaying the Output of a String that Contains Special Characters

The following example uses Unicode to parse the following French string:


The example specifies the LCID for the French language, 1036, and the ID of a user-defined stoplist, 5. Accent sensitivity is enabled.

SELECT * FROM sys.dm_fts_parser(N'français', 1036, 5, 1);  

Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL)
Full-Text Search
Configure and Manage Word Breakers and Stemmers for Search
Configure and Manage Thesaurus Files for Full-Text Search
Configure and Manage Stopwords and Stoplists for Full-Text Search
Query with Full-Text Search
Query with Full-Text Search

Community Additions

© 2016 Microsoft