Last Updated: February 10, 2021
·
31
· kalinin84

Full-Text search (MariaDB)

CREATE TABLE documents (
    id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    content TEXT NOT NULL
) ENGINE=InnoDB;
INSERT INTO documents (id, content) VALUES 
(1, 'Ad primos ictus non corruit ardua quercus'),
(2, 'Adprime in vita esse utile, ut ne quid nimis'),
(3, 'Benefacta male locata malefacta arbitror'),
(4, 'Citius, altius, fortius!'),
(5, 'Damnant, quod non intellegunt'),
(6, 'Hic mortui vivunt, hic muti loquuntur'),
(7, 'Nemo omnia potest scire');
ALTER TABLE documents ADD FULLTEXT (content);
SELECT *
FROM documents
WHERE MATCH (content) AGAINST ('non' IN NATURAL LANGUAGE MODE)
LIMIT 10;