Search code examples
mysqlsql-likematch-against

Mysql search engine like and match against


I hate 4000+ adverts on a database. I use a FULLTEXT index on fields title, model and description.

In MySQL I change the value of ft_min_word_len from 4 to 3.

Actually, all the results are not matched.

Here is a simple request :

SELECT * ,
    MATCH (
        anno_modele, anno_titre, anno_desc
    )
    AGAINST (
        "330"
    ) AS relevance
FROM (
    `annonce`

JOIN possede
USING ( `anno_id` )
JOIN annonceur
USING ( `ann_id` )
JOIN cat_lang
USING ( `cat_id` )
JOIN lang_pays
USING ( `pays_id` )
JOIN marque
USING ( `mar_id` )
WHERE `mar_id` =867
AND MATCH (
    anno_modele, anno_titre, anno_desc
)
AGAINST (
    " 330"
 )
AND `cat_id`
IN (
    '3'
)
AND `anno_active` =1
AND `anno_mode` =1
AND `lang_pays`.`lang_id` = '3'
GROUP BY `anno_id`
ORDER BY `anno_prix` , `relevance` DESC
LIMIT 15

This matches me 3 results. 330 is just the field "anno_model".

If if do a like anno_modele LIKE '%330%', it matches me 9 results.

Here are the results matched by MATCH AGAINST :

enter image description here

Here are the results matched by LIKE

enter image description here

As you can see, when it exists a space ... the results are not matched by MACTH AGAINST

Is the problem on my request or it's something else ?

Help me please =)


Solution

  • Try using the * wildcard

    ...AGAINST ('*330*') ...