Mysql full-text index query with SqlAlchemy

2017-11-24 作者:

结论:

  1. mysql fulltext index基本可用(试了natural language mode和boolean mode),尤其在表结构比较简单的前提下
  2. sqlalchemy自带的match关键字只能match单列的fulltext索引,多列的我们用如下办法自制 – 仅用于查询的话,完全够用
  3. 最重要的一点:数据量大时,一个query尽量只使用where match against,与其他的where some_column = ‘hello’要分开写(做成subquery)。如果写在一起,极有可能只有fulltext索引生效,而其他列的简单查询所对应的index不生效。

注册自己的Match子句

所有条件一起用于查询(前面1个filter不能触发已有index)

先做普通字段查询,join后再做fulltext检索(subquery和query各自使用自己的index)

参考自:https://stackoverflow.com/questions/14971619/proper-use-of-mysql-full-text-search-with-sqlalchemy

原创文章,转载请注明: 转载自渔人小径

本文链接地址: Mysql full-text index query with SqlAlchemy

打赏 PayPal

文章的脚注信息由WordPress的wp-posturl插件自动生成

完整阅读本篇»