보통 MySQL에서 FullText에 대해서 단어를 검색할 때 LIKE "%words%"를 주로 사용하기 마련이다.
하지만 이는 대용량 데이터에서 검색할 때는 느린 쿼리 결과를 보여준다.

먼저 FullText에 인덱싱을 걸어주자~!

CREATE FULLTEXT INDEX idx_1 ON my_search (text_data);
 

FullText에 대해서 빠르게 검색할 수 있는 방법이 있으니 MATCH, AGAINST 문법을 사용하면 된다.
FullText Indexing을 사용하는 방법으로 사용방법은

1. 기본적으로 words 에 대해 검색하고자 할 때
select * from table_name where MATCH(column_name) AGAINST("words")

2. words1과 words2를 포함한 것을 찾고자 할 때(이 때는 뒤에 IN BOOLEAN MODE라고 작성해 주어야 한다.)
select * from table_name where MATCH(column_name) 
AGAINST('+"words1" +"words2"' IN BOOLEAN MODE)

3. word1과 words2는 포함하고, words3는 포함하지 않는 것을 찾고자 할 때
select * from table_name where MATCH(column_name) 
AGAINST('+"words1" +"words2" -"words3"' IN BOOLEAN MODE)

참고문헌
http://dev.mysql.com/doc/refman/5.1/en/fulltext-boolean.html

+ Recent posts