BigInt类型可以进行全文搜索吗?

时间:2013-03-20 09:10:19

标签: mysql full-text-search pattern-matching

我正在使用以下查询来搜索文本

   $query = "SELECT SQL_CALC_FOUND_ROWS *," .
                "MATCH (keywords) AGAINST ('". $searchString ."'IN BOOLEAN MODE ) AS rel1, ".
                "MATCH (title) AGAINST ('". $searchString  ." 'IN BOOLEAN MODE ) AS rel2, ".
                "MATCH (description) AGAINST ('". $searchString  ." 'IN BOOLEAN MODE) AS rel3 ".
                "WHERE MATCH (keywords,title,description) AGAINST ('" .$searchString. "' IN BOOLEAN MODE) " .
                "FROM cron_video " .
                "ORDER BY (rel1*1.5)+(rel2*1.25)+(rel3*1) desc, `cron_status` ASC LIMIT $start, $pagesize";

但是,下面的搜索id的查询是错误的,它是BigInt类型。

$query = "SELECT SQL_CALC_FOUND_ROWS *," .
            "MATCH (id) AGAINST ('*". $searchString ."*' IN BOOLEAN MODE ) AS rel1," .          
            "FROM cron_video " . 
            "WHERE MATCH (id) AGAINST ('*" .$searchString. "*' IN BOOLEAN MODE) AS rel2" .
            "ORDER BY (rel1*1.5)+(rel2) desc, `cron_status` ASC LIMIT $start, $pagesize";

我的怀疑:
   1.对于BigInt类型,是否可以进行全文搜索。

关于第一个查询:

  1. 我不确定我能为相关因素(即)1.5(rel1 * 1.5),(rel2 * 1.25),rel3等提供什么价值......这个值本身是否足够,或者我如何确定最佳值相关因素。
  2. 有没有办法优化第一个查询。

1 个答案:

答案 0 :(得分:2)

From the documentation:

Full-text indexes can be used only with MyISAM tables, and can be created only for CHAR, VARCHAR, or TEXT columns.

请记住,SELECT * FROM ...不是表现友好的选择字段的方法。而是只选择您需要的字段。例如:SELECT f1, f2, f3 FROM t1。它会好得多。

修改

抱歉,我的错,在布尔模式下得分为0或1.所以你的代码是正确的。