全文搜索支持查询扩展(特别是其变体“盲目查询扩展”)。当搜索短语过短时,这通常非常有用,这往往意味着用户依赖于全文搜索引擎所缺乏的隐含知识。例如,一个搜索“数据库”的用户可能实际上是指“MySQL”、“Oracle”、“DB2”和“RDBMS”这些词都应该匹配“databases”并且也应返回。这就是隐含知识。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.
盲查询扩展(也称为自动相关性反馈)可以通过在搜索短语后添加 WITH QUERY
EXPANSION 或 IN NATURAL LANGUAGE MODE WITH
QUERY EXPANSION 来启用。其工作原理是执行两次搜索,第二次搜索的搜索短语是将第一次搜索中最相关的几个文档与原始搜索短语连接而成。因此,如果这些文档之一包含单词 “databases” 和单词 “MySQL”,第二次搜索会找到包含单词 “MySQL” 的文档,即使它们不包含单词 “databases”。以下示例显示了这种差异: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, if one of these documents contains the word
“databases” and the word “MySQL”, the
second search finds the documents that contain the word
“MySQL” even if they do not contain the word
“database”. The following example shows this
difference:
mysql>SELECT * FROM articlesWHERE MATCH (title,body)AGAINST ('database' IN NATURAL LANGUAGE MODE);+----+-------------------+------------------------------------------+ | id | title | body | +----+-------------------+------------------------------------------+ | 1 | MySQL Tutorial | DBMS stands for DataBase ... | | 5 | MySQL vs. YourSQL | In the following database comparison ... | +----+-------------------+------------------------------------------+ 2 rows in set (0.00 sec) mysql>SELECT * FROM articlesWHERE MATCH (title,body)AGAINST ('database' WITH QUERY EXPANSION);+----+-----------------------+------------------------------------------+ | id | title | body | +----+-----------------------+------------------------------------------+ | 5 | MySQL vs. YourSQL | In the following database comparison ... | | 1 | MySQL Tutorial | DBMS stands for DataBase ... | | 3 | Optimizing MySQL | In this tutorial we show ... | | 6 | MySQL Security | When configured properly, MySQL ... | | 2 | How To Use MySQL Well | After you went through a ... | | 4 | 1001 MySQL Tricks | 1. Never run mysqld as root. 2. ... | +----+-----------------------+------------------------------------------+ 6 rows in set (0.00 sec)
另一个例子可能是搜索乔治·西默农关于马格雷的书籍,当用户不确定如何拼写“马格雷”时。搜索“梅格雷与不情愿的证人”只会找到“马格雷与不情愿的证人”,如果没有查询扩展的话。使用查询扩展的搜索可以在第二次尝试时找到所有包含“马格雷”一词的书籍。Another example could be searching for books by Georges Simenon about Maigret, when a user is not sure how to spell “Maigret”. A search for “Megre and the reluctant witnesses” finds only “Maigret and the Reluctant Witnesses” without query expansion. A search with query expansion finds all books with the word “Maigret” on the second pass.
由于盲查询扩展往往会通过返回无关文档显著增加噪音,因此仅在搜索短语较短时使用它。Because blind query expansion tends to increase noise significantly by returning nonrelevant documents, use it only when a search phrase is short.