zoukankan      html  css  js  c++  java
  • MySQL 全文搜索支持

    1. MySQL 全文搜索支持  
    2.   
    3. 从MySQL 4.0以上 myisam引擎就支持了full text search 全文搜索,在一般的小网站或者blog上可以使用这个特性支持搜索。  
    4. 那么怎么使用了,简单看看:  
    5.   
    6. 1.创建一个表,指定支持fulltext的列  
    7.   
    8.     CREATE TABLE articles (  
    9.         id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,  
    10.         title VARCHAR(200),  
    11.         body TEXT,  
    12.         FULLTEXT (title,body)  
    13.     );  
    14.       
    15. 2.插入一些数据作为测试  
    16.   
    17.     INSERT INTO articles (title,body) VALUES  
    18.         ('MySQL Tutorial','DBMS stands for DataBase ...'),  
    19.         ('How To Use MySQL Well','After you went through a ...'),  
    20.         ('Optimizing MySQL','In this tutorial we will show ...'),  
    21.         ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),  
    22.         ('MySQL vs. YourSQL','In the following database comparison ...'),  
    23.         ('MySQL Security','When configured properly, MySQL ...');  
    24.           
    25. 3.select查询fulltext的列   
    26.   
    27.     SELECT * FROM articles  
    28.         WHERE MATCH (title,body) AGAINST ('database');  
    29.           
    30. 查询结果:  
    31.   
    32.     5        MySQL vs. YourSQL        In the following database comparison ...      
    33.     1        MySQL Tutorial               DBMS stands for DataBase ...     
    34.       
    35. 全文查询中的boolean语句, + -跟普通的搜索引擎语法一样  
    36.   
    37.     SELECT * FROM articles WHERE MATCH (title,body)  
    38.          AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE);  
    39.            
    40. innodb不支持fulltext,当然可以使用http://sphinxsearch.com/ sphinx来dump数据库数据支持全文搜索。  
  • 相关阅读:
    express 的安全中间件 helmet 简介
    一个设置过期时间的方案
    vscode 中的 vue 格式化
    linux 中部署不同版本 node.js 并同时使用的方案
    webpack 多页面模式配置
    1.assert
    我是一个线程(转)
    Android FragmentTransactionExtended:使Fragment以多种样式动画切换
    Android ORM应用开发框架KJFrameForAndroid使用详解
    Android Studio插件推荐(PreIOC,GsonFormat)
  • 原文地址:https://www.cnblogs.com/focai/p/4489804.html
Copyright © 2011-2022 走看看