sys.dm_fts_parser (Transact-SQL)

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.

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_id

int

Contain 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:

group_id display_term

1Server

2DB

3DB

phrase_id

int

Contains 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:

phrase_id display_term

1multi

1million

2multimillion

occurrence

int

Indicates 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:

occurrence display_term

1SQL

2Server

3query

4processor

special_term

nvarchar(8000)

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_term

nvarchar(8000)

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_type

int

Contains 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:

<expansion>

<sub>run</sub>

<sub>jog</sub>

</expansion>

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_term

nvarchar(8000)

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:

Using Unicode for Parsing Special Characters

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.

When to Use sys.dm_fts_parser

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:

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.