MySQL 全文檢索搜尋支援

來源:互聯網
上載者:User

標籤:

  1. MySQL 全文檢索搜尋支援  
  2.   
  3. 從MySQL 4.0以上 myisam引擎就支援了full text search 全文檢索搜尋,在一般的小網站或者blog上可以使用這個特性支援搜尋。  
  4. 那麼怎麼使用了,簡單看看:  
  5.   
  6. 1.建立一個表,指定支援fulltext的列  
  7.   
  8.     CREATE TABLE articles (  
  9.         id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,  
  10.         title VARCHAR(200),  
  11.         body TEXT,  
  12.         FULLTEXT (title,body)  
  13.     );  
  14.       
  15. 2.插入一些資料作為測試  
  16.   
  17.     INSERT INTO articles (title,body) VALUES  
  18.         (‘MySQL Tutorial‘,‘DBMS stands for DataBase ...‘),  
  19.         (‘How To Use MySQL Well‘,‘After you went through a ...‘),  
  20.         (‘Optimizing MySQL‘,‘In this tutorial we will show ...‘),  
  21.         (‘1001 MySQL Tricks‘,‘1. Never run mysqld as root. 2. ...‘),  
  22.         (‘MySQL vs. YourSQL‘,‘In the following database comparison ...‘),  
  23.         (‘MySQL Security‘,‘When configured properly, MySQL ...‘);  
  24.           
  25. 3.select查詢fulltext的列   
  26.   
  27.     SELECT * FROM articles  
  28.         WHERE MATCH (title,body) AGAINST (‘database‘);  
  29.           
  30. 查詢結果:  
  31.   
  32.     5        MySQL vs. YourSQL        In the following database comparison ...      
  33.     1        MySQL Tutorial               DBMS stands for DataBase ...     
  34.       
  35. 全文檢索查詢中的boolean語句, + -跟普通的搜尋引擎文法一樣  
  36.   
  37.     SELECT * FROM articles WHERE MATCH (title,body)  
  38.          AGAINST (‘+MySQL -YourSQL‘ IN BOOLEAN MODE);  
  39.            
  40. innodb不支援fulltext,當然可以使用http://sphinxsearch.com/ sphinx來dump資料庫資料支援全文檢索搜尋。  

MySQL 全文檢索搜尋支援

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.