content_image/792345.jpg content_image/792347.jpg content_image/792349.jpg content_image/792350.jpg
## Relevancy Ranking for a Multiple Word Search 

<img src='content_image/792345.jpg'>

performed elsewhere, such as in the MySQL command-line client or other types of calculators. 

This example demonstrates the relevancy ranking calculation for a multiple-word full-text search based on the articles  table and data used in the previous example. 

If you search on more than one word, the relevancy ranking value is a sum of the relevancy ranking value for each word, as shown in this formula: 

${rank} = ${TF} * ${IDF} * ${IDF} + ${TF} * ${IDF} * ${IDF} 

Performing a search on two terms (’mysql tutorial’) returns the following results: 

mysql> SELECT id, title, body, MATCH (title,body) AGAINST (’mysql tutorial’ IN BOOLEAN MODE) AS score FROM articles ORDER BY score DESC; 

<img src='content_image/792347.jpg'>

In the first record ( id 8 ), ’mysql’ appears once and ’tutorial’ appears twice. There are six matching records for ’mysql’ and two matching records for ’tutorial’. The MySQL command-line client returns the expected ranking value when inserting these values into the ranking formula for a multiple word search: 

## 12.10.3 Full-Text Searches with Query Expansion 

mysql> SELECT (1*log10(8/6)*log10(8/6)) + (2*log10(8/2)*log10(8/2)); +-------------------------------------------------------+ | (1*log10(8/6)*log10(8/6)) + (2*log10(8/2)*log10(8/2)) | +-------------------------------------------------------+ | 0.7405621541938003 | +-------------------------------------------------------+ 1 row in set (0.00 sec) 

<img src='content_image/792349.jpg'>

<img src='content_image/792350.jpg'>

## Note 

The slight difference in the ranking values returned by the SELECT ... MATCH ... AGAINST  statement and the MySQL command-line client is explained in the preceding example. 

Full-text search supports query expansion (and in particular, its variant “blind query expansion” ). This is generally useful when a search phrase is too short, which often means that the user is relying on implied knowledge that the full-text search engine lacks. For example, a user searching for “database”  may really mean that “MySQL” , “Oracle” , “DB2” , and “RDBMS”  all are phrases that should match “databases”  and should be returned, too. This is implied knowledge. 

Blind query expansion (also known as automatic relevance feedback) is enabled by adding WITH QUERY EXPANSION  or IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION  following the search phrase. It works by performing the search twice, where the search phrase for the second search is the original search phrase concatenated with the few most highly relevant documents from the first search. Thus, 

