MySQL uses match...against for full-text retrieval

Source: Internet
Author: User

In the e-commerce project, one of the core functions is the search function, search done well, the entire e-commerce platform is an excellent platform. General search functions are using search engines such as Lucene, SOLR, Elasticsearch, and so on, although this function is more powerful, but for some small companies or small e-commerce platform project a bit overqualified, for small projects we can use a compromise method, using ik+ MySQL search engine query, IK for word segmentation, MySQL use match and against function for fuzzy query. Write down the usage of MySQL match and against first.

1 1 , add a fulltext index to the Mm_product table Name,label field.   2 ALTER TABLE ' mm_product '   3 ADD fulltext INDEX ' name1 ' (' name ');   4 ALTER TABLE ' mm_product '   5 ' Label1 '  ('label');  

1 2 , using the match and against  functions 2 Select  from where match (Name,label) against (' White cat dishwashing detergent ');  
In the WHERE clause of select with the match function, the index keyword is identified with against, in BOOLEAN mode is only the key word on the line, do not care about the location, is not the starting position.

MySQL uses match...against for full-text retrieval

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.