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 |
+ ---------- + ------------ + ---------- + -------------- + ------------- +