Home  >  Q&A  >  body text

java - MySQL 能否实现检索关键字功能?

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

PHP中文网PHP中文网2741 days ago551

reply all(4)I'll reply

  • 阿神

    阿神2017-04-18 10:26:56

    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...

    reply
    0
  • 黄舟

    黄舟2017-04-18 10:26:56

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

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:26:56

    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

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 10:26:56

    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.

    reply
    0
  • Cancelreply