Use Mysql Full-Text search Full-Text (fulltext and match... against)

Source: Internet
Author: User
Tags mysql manual

 

Author: aolinks

Although this method is feasible,

 

However, for full-text search, this is an extremely inefficient method, especially when processing a large amount of data.

 

-------------------

The above sentence I saw on the Internet makes sense. mysql itself provides a technology called full-text search,

 

However, this seems to have been available only in later versions. Older versions are not supported, but it is an earlier version,

 

Currently, all versions are supported. I am using mysql6.0.4 for demonstration now

 

I think full-text search is more comprehensive than index search. The index only applies to a certain field, and then uses like in combination during query.

 

For full-text search, you can set multiple fields for search, which is more advanced than select... like.

 

Well, since full-text search has such advantages, let's see if it is true.

 

The test example provided below is an example in the mysql manual.

 

Create table articles (

 

Id int unsigned AUTO_INCREMENT not null primary key,

 

Title VARCHAR (200 ),

 

Body TEXT,

 

FULLTEXT (title, body)

 

);

 

This is the mysql statement used to create a table. The last FULLTEXT (title, body)

 

Creates a full-text search for the title and body.

 

Body of the title. Copy the statement to create a table.

Check whether full-text search is created. The following statement is used to view the table's primary key, index, and full-text search.

 

Show indexes from Table Name

 

Mysql> show indexes from articles;

+ ---------- + ------------ + ---------- + -------------- + ------------- +

| Table | Non_unique | Key_name | Seq_in_index | Column_name |

+ ---------- + ------------ + ---------- + -------------- + ------------- +

| Articles | 0 | PRIMARY | 1 | id |

| Articles | 1 | title | 1 | title |

| Articles | 1 | title | 2 | body |

+ ---------- + ------------ + ---------- + -------------- + ------------- +

Related Article

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.