Full-text indexing in MySQL

Source: Internet
Author: User

Previously published an article on SQL Server full-text indexing. Now Log The configuration process for the MySQL full-text index.

Step1: CreateStudentTable

CREATE TABLE ' Student ' (

' ID ' INT (one) not NULL auto_increment,

' Studentname ' VARCHAR (+) not NULL,

' Address ' VARCHAR DEFAULT ' Beijing ',

' Gender ' TINYINT (4) Not NULL,

' Mymoney ' DECIMAL (18,2) DEFAULT NULL,

PRIMARY KEY (' id '),

Fulltext KEY ' studentname ' (' Studentname ')

) Engine=myisam Charset=utf8

STEP2:inserting test Data

INSERT into ' xsh '. ' Student '

(

' Studentname ',

' Address ',

' Gender ',

' Mymoney ')

VALUES (

' Happy Love happy ',

' Beijing ',

1,

1);

Step3: ModifyMy.inifile, restart service

My.ini (Linux is my.cnf ), add a line after [mysqld] Ft_ Min_word_len=1 ", then restart Mysql

Results can be viewed through show VARIABLES like ' Ft_min_word_len '

Step4: Ignore weight query(There is only one piece of data in the table)

MySQL default threshold is 50%, above 'you ' in each document appears, therefore is 100%, only below   50% will appear in the result set. But what if the weights are not taken into account? MySQL provides a Boolean full-text Search (boolean fulltext search)

SELECT * FROM Student

WHERE MATCH (studentname) against (' Love ' in BOOLEAN MODE)

This is only a simple record because the full-text index is based on participle, but MySQL does not support Chinese. Need to achieve @ by plugins or by other means !

Full-text indexing in MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.