MySQL 에서 제공하는 Full Text Search

MySQL 에서인덱스는 BLOB 나 TEXT 데이터형에는 사용할 수 없었으나 Full Text Search 는

TEXT, VARCHAR ,CHAR 컬럼에 인덱스를 사용 가능하게 해준다.

 

Syntax

ALTER TABLE table_name ADD FULLTEXT [index_name] (index_col_name, .... ) or

CREATE FULLTEXT INDEX index_name ON table_name (col_name[(length)], ... )

 

실제로 Query 를 이용할 때는 MATCH()~AGAINST() 를 사용한다.

  1. 최소한 필요한 문자의 길이는 4자 이상
  2. 3자 이하는 검색이 되지 않는다.
  3. 보통 noise word ( "the, for, as,  in, to ... " ) 등은 검색이 되지 않는다.
  4. GRIP 에서는 Full Text Search 시 "gene, protein .. " 같은 단어또한 noise word 라고 생각됨
  5. noise word 는 추가가 가능하고 소스 파일 myisam/ft_static.c 에 내용이 들어있다. 이 파일에 내용을 추가하고 재 컴파일 가능

 

실제 사용 예

mysql> select locusid, summary from LocusLink where match(summary) against('"adenocarcinoma cells"' in boolean mode);
 

*************************** 1. row ***************************
locusid: 14
summary: The gene product is an immunoglobulin-type protein. It is found to be expressed strongly in endothelial cells, cytotrophoblasts, and poorly differentiated colon adenocarcinoma cells found in lymphatics. The protein contains a heparin-binding domain and mediates heparin-sensitive cell adhesion.
 

*************************** 2. row ***************************
locusid: 25859
summary: This gene is induced by androgen in prostate adenocarcinoma cells. Transcript variants utilizing alternative polyadenylation signals have been described in the literature.
2 rows in set (0.00 sec)