Chapter XVIII: full-text search

@author: Tobin
@date: 2019/11/4 16:03:15

MyISAM does not support full-text search, InnoDB support.

# 在创建表时启用全文本搜索
CREATE TABLE productnotes
(
    note_id int NOT NULL AUTO_INCREMENT,
    prod_id char(10) NOT NULL,
    note_date datetime NOT NULL
    note_text text NULL,
    PRIMARY KEY(note_id),
    FULLTEXT(note_text)
) ENGINE=MyISAM;

# 进行全文本搜索
SELECT note_text
FROM productnotes
WHERE Match(note_text) Against('rabbit');

# 使用查询扩展
SELECT note_text
FROM productnotes
WHERE Match(note_text) Against('anvils' WITH QUERY EXPANSION);

# 布尔文本搜索,没有定义FULLTEXT索引也可以使用
SELECT note_text
FROM productnotes
WHERE Match(note_text) Against('heavy -rope*' IN BOOLEAN MODE);

FROM employees ep
LEFT JOIN dept_emp dp
ON ep.emp_no = dp.emp_no

Guess you like

Origin www.cnblogs.com/zuotongbin/p/11814168.html