1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
DROP TABLE IF EXISTS memos;
SET NAMES utf8;
CREATE TABLE memos (
id INT PRIMARY KEY,
title VARCHAR(255),
content TEXT,
FULLTEXT INDEX (title, content)
) DEFAULT CHARSET=utf8;
INSERT INTO memos VALUES(1, "Groonga", "Groonga is fast.");
INSERT INTO memos VALUES(2, "Mroonga", "Mroonga is also fast.");
INSERT INTO memos VALUES(3, "Rroonga", "Rroonga is also fast.");
SELECT *,
MATCH(title, content)
AGAINST("*W1:10,2:2DOR Groonga Mroonga" in BOOLEAN MODE) AS score
FROM memos
WHERE MATCH(title, content)
AGAINST("*W1:10,2:2DOR Groonga Mroonga" in BOOLEAN MODE);
id title content score
1 Groonga Groonga is fast. 12
2 Mroonga Mroonga is also fast. 12
DROP TABLE memos;
|