Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What should be paid attention to in the implementation of full-text search in FULLTEXT of MySQL

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

With the development of the Internet, more and more people have entered the IT industry, so what do we need to pay attention to when realizing full-text retrieval in MySQL FULLTEXT? You know what? In order to let you know more about the SQL database, the editor summarizes the following contents. Let's look down together.

For English, MySQL's FULLTEXT attribute to achieve full-text search is quite convenient and efficient, but need to pay attention to some matters in the process of using MySQL's FULLTEXT to achieve full-text search do you know how much, in fact, this thing Xiaobian test does not support Chinese, but since used there are still some things to pay attention to.

First, add the FULLTEXT attribute to the field we need to retrieve (assuming the table has been created):

Alter table table_name add fulltext index (filed_1,filed_2)

Next, query the data:

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

There is a very important note here:

MySQL stipulates that when the number of lines of the searched word in the full-text search is greater than or equal to half of all the lines searched, the searched word will be used as Common word, that is, it will not be displayed. (the specific conditions need to be determined by consulting the data)

Therefore, assume that when testing, there is only one row of data in the table, so no matter how the above query statement is executed, the result returned is always empty. There is no need to panic, add a few more pieces of data with no keywords to be checked, and there will be results.

Of course, MySQL provides more powerful filtering of query results:

SELECT * FROM table_name WHERE MATCH (filed_1,filed_2) AGAINST ('keyword_1-keyword_2' IN BOOLEAN MODE)

In this way, the data containing keyword_1 is returned, and the data containing keyword_2 is filtered out.

These are the details of what you need to pay attention to in MySQL's FULLTEXT full-text search, and do you have anything to gain after reading it? If you want to know more about it, welcome to the industry information.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report