About MySQL Fulltext to implement full-text search considerations

Source: Internet
Author: User

For English, MySQL's Fulltext property is quite convenient and efficient to implement full-text retrieval, but there are some things to be aware of in the process of using.

First, we add the Fulltext attribute to the field we need to retrieve (assuming the table is already built):

Sql:

ALTER TABLE TABLE_NAME ADD FULLTEXT index (FILED_1,FILED_2);

Next, query the data:

Sql:

SELECT * FROM table_name WHERE MATCH (filed_1,filed_2) against (' keyword ');

Here is a very important consideration:

MySQL specifies that when the word searched in full-text search is more than half the number of rows that are searched, the word will be searched as common word, which is not displayed. (Specific conditions need to check the information to determine)

So, assuming that there is only one row of data in the table at the time of the test, the returned result is always empty no matter how the query is executed. Do not panic, add a few unknown origin keyword data will have the result ~

Of course, MySQL provides a more powerful filter for query results:

Sql:

SELECT * FROM table_name WHERE MATCH (filed_1,filed_2) against (' +keyword_1-keyword_2 ' in BOOLEAN MODE);

This will return the data containing the keyword_1 , and the data containing the keyword_2 will be filtered out.

? ? ? ? ? ? ? ? Original address: http://www.luoning.me/mysql-fulltext.html

About MySQL Fulltext to implement full-text search considerations

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.