mysql全文索引:MySQL全文搜索来源: 发布时间:星期日, 2009年1月4日 浏览:71次 评论:0
="t18">全文索引在 MySQL 中是
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 全文搜索通过MATCH ![]() ![]() ![]() mysql> CREATE TABLE articles ( -> id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, -> title VARCHAR(200), -> body TEXT, -> FULLTEXT (title,body) -> ); Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO articles VALUES -> (NULL,'MySQL Tutorial', 'DBMS stands for DataBase ...'), -> (NULL,'How To Use MySQL Efficiently', 'After you went through a ...'), -> (NULL,'Optimising MySQL','In this tutorial we will show ...'), -> (NULL,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), -> (NULL,'MySQL vs. YourSQL', 'In the following database comparison ...'), -> (NULL,'MySQL Security', 'When configured properly, MySQL ...'); Query OK, 6 rows affected (0.00 sec) Records: 6 Duplicates: 0 Warnings: 0 mysql> SELECT * FROM articles -> WHERE MATCH (title,body) AGAINST ('database'); +----+-------------------+------------------------------------------+ | id | title | body | +----+-------------------+------------------------------------------+ | 5 | MySQL vs. YourSQL | In the following database comparison ... | | 1 | MySQL Tutorial | DBMS stands for DataBase ... | +----+-------------------+------------------------------------------+ 2 rows in ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 当MATCH ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 它也可以执行 ![]() ![]() ![]() ![]() ![]() 前面 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 下 ![]() ![]() ![]() ![]() ![]() ![]() ![]() mysql> SELECT id,MATCH (title,body) AGAINST ('Tutorial') FROM articles; +----+-----------------------------------------+ | id | MATCH (title,body) AGAINST ('Tutorial') | +----+-----------------------------------------+ | 1 | 0.64840710366884 | | 2 | 0 | | 3 | 0.66266459031789 | | 4 | 0 | | 5 | 0 | | 6 | 0 | +----+-----------------------------------------+ 6 rows in ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() mysql> SELECT id, body, MATCH (title,body) AGAINST -> ('Security implications of running MySQL as root') AS score -> FROM articles WHERE MATCH (title,body) AGAINST -> ('Security implications of running MySQL as root'); +----+-------------------------------------+-----------------+ | id | body | score | +----+-------------------------------------+-----------------+ | 4 | 1. Never run mysqld as root. 2. ... | 1.5055546709332 | | 6 | When configured properly, MySQL ... | 1.31140957288 | +----+-------------------------------------+-----------------+ 2 rows in ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 在集和查询中 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 这样 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() mysql> SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('MySQL'); Empty ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 匹配表中 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 到 4.0.1 时 ![]() ![]() ![]() mysql> SELECT * FROM articles WHERE MATCH (title,body) -> AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); +----+------------------------------+-------------------------------------+ | id | title | body | +----+------------------------------+-------------------------------------+ | 1 | MySQL Tutorial | DBMS stands for DataBase ... | | 2 | How To Use MySQL Efficiently | After you went through a ... | | 3 | Optimising MySQL | In this tutorial we will show ... | | 4 | 1001 MySQL Tricks | 1. Never run mysqld as root. 2. ... | | 6 | MySQL Security | When configured properly, MySQL ... | +----+------------------------------+-------------------------------------+这个查询返回所有包含词MySQL ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 逻辑全文搜索支持下面 ![]() + ![]() ![]() ![]() ![]() ![]() - ![]() ![]() ![]() ![]() ![]() 缺省 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() < > 这两个操作符用于改变 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ( ) 圆括号用于对子表达式中 ![]() ![]() ~ ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() * ![]() ![]() ![]() ![]() ![]() ![]() ![]() " 短语 ![]() ![]() ![]() ![]() ![]() ![]() ![]() 这里是 ![]() apple banana 找至少包含上面词中 ![]() ![]() ![]() +apple +juice ... 两个词均在被包含 +apple mac ![]() ... 包含词 “apple” ![]() ![]() ![]() ![]() ![]() +apple -mac ![]() ... 包含 “apple” 但不包含 “mac ![]() +apple +(>pie <strudel) ... 包含 “apple” 和 “pie” ![]() ![]() ![]() ![]() apple* ... 包含 “apple” ![]() ![]() "some words" ... 可以包含 “some words of wisdom” ![]() 全文 ![]() MATCH ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() MATCH ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() AGAINST ![]() ![]() ![]() ![]() ![]() 微调 MySQL 全文搜索 不幸地 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 注意 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 被索引 ![]() ![]() ![]() stopword 列表可以从ft_stopword_file变量指定 ![]() ![]() 50% 阈值选择由所选择 ![]() ![]() ![]() ![]() ![]() ![]() # ![]() # ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 有时 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() mysql> REPAIR TABLE tbl_name QUICK;全文搜索 TODO 使所有对FULLTEXT索引 ![]() 邻近(Proximity)操作符 对 "always-index words" ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 支持在MERGE表中 ![]() 对多字节 ![]() ![]() 依照数据 ![]() Stemming (当然 ![]() ![]() Generic user-suppliable UDF preparser. 使模式更加灵活 (通过为CREATE/ALTER TABLE中 ![]() 0
相关文章读者评论发表评论 |
|