java - MySQL 能否实现检索关键字功能?
PHP中文网
PHP中文网 2017-04-18 10:24:56
0
4
600

用户在文本编辑器中,输入文字。如何使用 sql 查询那段文字中是否存在关键字?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
阿神

What you are talking about should belong to full-text search.
MYSQL only supports full-text search for MYISAM and does not support Chinese. There are other third-party methods that use search engines and MYSQL to achieve high-performance full-text retrieval solutions.
For details, please refer to:
http://wenku.baidu.com/link?u...

黄舟

Can you describe the requirements in more detail? What kind of functional requirements do you want to make?

大家讲道理

You are talking about full-text indexing. InnoDB in Mysql5.7 supports full-text indexing (I don’t know about other versions), and has a built-in ngram full-text search plug-in to support Chinese word segmentation.

When creating a table: FULLTEXT (字段1,字段2) WITH PARSER ngram
When querying:

SELECT COUNT(*) FROM table1
WHERE MATCH (字段1,字段2) AGAINST ('关键词');

For more details, please visit the official website

左手右手慢动作

Well, you can use elasticsearch to search. Of course, this does not belong to mysql. MySQL itself is used for storage. For complex search word segmentation and so on, it is better to use professional ones. Many e-commerce companies also use this.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template