MySQL全文檢索的實現(xiàn)示例
不是所有的數(shù)據(jù)表都支持全文檢索 MySQL支持多種底層數(shù)據(jù)庫引擎,但是并非所有的引擎支持全文檢索 ,目前最常用引擎是是MyISAM和InnoDB;前者支持全文檢索,后者不支持。
booolean模式操作符
| 操作符 | 含義 |
| + | 必須有 |
| - | 必須不包含 |
| > | 包含對應(yīng)關(guān)鍵字的排名靠前 |
| < | 包含對應(yīng)關(guān)鍵字的排名靠后 |
| ~ | 取反() |
| * | 放在詞尾 類似通配符 |
| " " | 引號中間作為一個完整的值處理 |
實驗:
表productnotes :

1.查詢包含rabbit的行,并按照相關(guān)性排序
mysql> SELECT note_text
-> FROM productnotes
-> WHERE Match(note_text) Against('rabbit');
+----------------------------------------------------------------------------------------------------------------------+
| note_text |
+----------------------------------------------------------------------------------------------------------------------+
| Customer complaint: rabbit has been able to detect trap, food apparently less effective now. |
| Quantity varies, sold by the sack load. All guaranteed to be bright and orange, and suitable for use as rabbit bait. |
+----------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.01 sec)
2.顯示每一條的相關(guān)性值
mysql> SELECT note_text,
-> Match(note_text) Against('rabbit') AS match_rank
-> FROM productnotes;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+
| note_text | match_rank |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+
| Customer complaint:
Sticks not individually wrapped, too easy to mistakenly detonate all at once.
Recommend individual wrapping. | 0 |
| Can shipped full, refills not available.
Need to order new can if refill needed. | 0 |
| Safe is combination locked, combination not provided with safe.
This is rarely a problem as safes are typically blown up or dropped by customers. | 0 |
| Quantity varies, sold by the sack load.
All guaranteed to be bright and orange, and suitable for use as rabbit bait. | 1.5905543565750122 |
| Included fuses are short and have been known to detonate too quickly for some customers.
Longer fuses are available (item FU1) and should be recommended. | 0 |
| Matches not included, recommend purchase of matches or detonator (item DTNTR). | 0 |
| Please note that no returns will be accepted if safe opened using explosives. | 0 |
| Multiple customer returns, anvils failing to drop fast enough or falling backwards on purchaser. Recommend that customer considers using heavier anvils. | 0 |
| Item is extremely heavy. Designed for dropping, not recommended for use with slings, ropes, pulleys, or tightropes. | 0 |
| Customer complaint: rabbit has been able to detect trap, food apparently less effective now. | 1.6408053636550903 |
| Shipped unassembled, requires common tools (including oversized hammer). | 0 |
| Customer complaint:
Circular hole in safe floor can apparently be easily cut with handsaw. | 0 |
| Customer complaint:
Not heavy enough to generate flying stars around head of victim. If being purchased for dropping, recommend ANV02 or ANV03 instead. | 0 |
| Call from individual trapped in safe plummeting to the ground, suggests an escape hatch be added.
Comment forwarded to vendor. | 0 |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+
14 rows in set (0.00 sec)
3.有heavy 但是沒有rope
mysql> SELECT note_text
-> FROM productnotes
-> WHERE Match(note_text)
-> Against('heavy -rope*' IN BOOLEAN MODE);
+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| note_text |
+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Customer complaint:
Not heavy enough to generate flying stars around head of victim. If being purchased for dropping, recommend ANV02 or ANV03 instead. |
+---------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)到此這篇關(guān)于MySQL 全文檢索的文章就介紹到這了,更多相關(guān)MySQL 全文檢索內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
mysql5.7.18.zip免安裝版本配置教程(windows)
這篇文章主要為大家詳細(xì)介紹了mysql5.7.18.zip安裝教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05
簡單解決Windows中MySQL的中文亂碼與服務(wù)啟動問題
這篇文章主要介紹了Windows中MySQL的中文亂碼與服務(wù)啟動問題,如果程序沒有特殊需要則建議MySQL盡量默認(rèn)設(shè)為UTF-8格式編碼,需要的朋友可以參考下2016-03-03
MySQL如何快速批量插入1000w條數(shù)據(jù)
這篇文章主要給大家介紹了關(guān)于MySQL如何快速批量插入1000w條數(shù)據(jù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03
查看本地MYSQL數(shù)據(jù)庫IP地址的三種方法
本文介紹了多種方法來查看連接到本地MySQL服務(wù)器的IP地址,括使用SQL查詢從`information_schema.processlist`獲取IP地址,并通過`group by`進(jìn)行統(tǒng)計,以及通過命令行工具如`mysql`和`awk`進(jìn)行過濾和計數(shù),這些方法有助于監(jiān)控和管理數(shù)據(jù)庫連接,需要的朋友可以參考下2024-10-10
Mysql查詢正在執(zhí)行的事務(wù)以及等待鎖的操作方式
今天小編就為大家分享一篇關(guān)于Mysql查詢正在執(zhí)行的事務(wù)以及等待鎖的操作方式,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2018-12-12
MySQL中表子查詢與關(guān)聯(lián)子查詢的基礎(chǔ)學(xué)習(xí)教程
這篇文章主要介紹了MySQL中表子查詢與關(guān)聯(lián)子查詢的基礎(chǔ)學(xué)習(xí)教程,同時文中也提到了關(guān)于關(guān)聯(lián)子查詢的查詢效率問題,需要的朋友可以參考下2015-12-12
mysql5.7同時使用group by和order by報錯問題
這篇文章主要介紹了mysql5.7同時使用group by和order by報錯的問題及解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-08-08
mysql error 1071: 創(chuàng)建唯一索引時字段長度限制的問題
這篇文章主要介紹了mysql error 1071: 創(chuàng)建唯一索引時字段長度限制的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-09-09

