全文搜索无法正常工作

时间:2017-11-07 17:57:47

标签: mysql full-text-search

如果我输入8in Wrench这样的描述,我希望得到像WRENCH ADJUSTABLE CRESCENT 8IN这样的结果,但我找不到结果。如果我搜索Adjustable WrenchCrescent Wrench它可以正常工作,但不适用于8in wrench

为什么不返回所需的结果?

这是mysql查询

$term = request()->term;
$exp = explode(' ', $term);

$s = '';
$c = 1;
foreach ($exp AS $e)
{
    $s .= "+$e*";

    if ($c + 1 == count($exp))
        $s .= ' ';

    $c++;
}


SELECT
   `items`.`*`,
   `itemunits`.`*`,
   `vendoritems`.`*`,
FROM
   `items` 
   INNER JOIN
      `itemunits` 
      ON `itemunits`.`itemcode` = `items`.`itemcode` 
   INNER JOIN
      `vendoritems` 
      ON `vendoritems`.`itemcode` = `items`.`itemcode` 
WHERE
   (
      `items`.`deleted` = 0 
      AND `vendoritems`.`deleted` = 0 
   )
   AND 
   (
      MATCH (items.description) AGAINST ( $s IN BOOLEAN MODE) 
      OR MATCH (vendoritems.partnumber) AGAINST ('$s' IN BOOLEAN MODE)
   )
GROUP BY
   `items`.`itemcode`,
   `vendoritems`.`itemcode`,
   `itemunits`.`itemcode` 
ORDER BY
   items.description"

0 个答案:

没有答案