search

Home  >  Q&A  >  body text

mysql - 两个全文索引的字段能否并在一起查询

字段:title,article,都是全文索引。

查询关键词:key1,key2,key3。

SELECT * FROM [表名] WHERE MATCH(article) AGAINST('key1,key2,key3');针对一个全文检索的字段是可行的

有没有这种:

SELECT * FROM [表名] WHERE MATCH(title,article) AGAINST('key1,key2,key3');

即同时在title+abstract中查找key1,key2,key3。但错误提示:Can't find FULLTEXT index matching the column list

有没有好办法?

PHP中文网PHP中文网2788 days ago846

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-17 14:58:21

    alter table aws_articles add fulltext(title,abstract); It’s ok. Create a joint index, but building it alone will not work

    reply
    0
  • 阿神

    阿神2017-04-17 14:58:21

    Which version of MySQL is it? Does full-text search support Chinese?

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 14:58:21

    If it is an English field, as @haixia9060 said, you can create a new index and query

    1. Create a new index on three fields

      ALTER TABLE articles ADD FULLTEXT content_title_keywords_ndx (content,title,keywords);
      
    2. Query

      match(content,title,keywords) against ('cats' in boolean mode)
      

      MySQL can only handle English/numeric types by default;

    If it is a Chinese field, the inverted index should be maintained according to the process (Document->Token->Term->Index);
    There is also a MySQL field specified by Analyzer to automatically maintain the index and synchronize it to Solr in real time. How to perform full-text indexing;

    reply
    0
  • Cancelreply