0

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

   $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. 有什么方法可以优化第一个查询。
4

1 回答 1

2

从文档中:

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。所以你的代码是正确的。

于 2013-03-20T09:12:35.263 回答