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