Search code examples
mysqlfull-text-searchmatch-against

Mysql Full-text search with plus sign


I have got a problem.

In my MySql db i have 40000 row in product table. Table has an column called T9Text. One of my row T9Text area is like this:

UNISNLS106B UNI.SNLS 106B SNLS-106B M.OT. 12V 2 DELİK MOTOR CRAFT TİPİ UNIPOINT 66-205 66205 F02Z-11390-A F02Z11390A E90Z-11390-A E90Z11390A F4DZ-11390-A F4DZ11390A F3VY-11390-A F3VY11390A E90Z-11390-A E90Z11390A FORD ESCORT MERCURY TRACER FORD

For auto complete process, I run a stored procedure in db. It is like that:

SELECT p.Code, 
  p.Name,
  p.`T9Text`,
  MATCH (p.T9Text) AGAINST ('+UNI* +SNLS* +106B*' IN BOOLEAN MODE) AS SCORE
FROM product p
WHERE MATCH (p.T9Text) AGAINST ('+UNI* +SNLS* +106B*' IN BOOLEAN MODE) >0
GROUP BY p.Name
ORDER BY SCORE DESC

Like this, it works great and return just one row.

But i need to write my where condition like this:

MATCH (p.T9Text) AGAINST ('+*UNI* +*SNLS* +*106B*' IN BOOLEAN MODE) >0

With above code it returns 1877 rows. It is like plus sign doesn't work

MATCH (p.T9Text) AGAINST ('+*UNISNLS106B*' IN BOOLEAN MODE) >0
MATCH (p.T9Text) AGAINST ('+*NISNLS106B*' IN BOOLEAN MODE) >0

With first query return 1 row, but second query returns 0 row.

So, there is my question: In mysql fulltext search, can not I use +test expression? If not, is there any way to do this? (except LIKE)


Solution

  • From the Boolean Full-Text Search docs;

    The asterisk serves as the truncation (or wildcard) operator. Unlike the other operators, it should be appended to the word to be affected. Words match if they begin with the word preceding the * operator.

    In other words, boolean search does not support "contains" using the * operator.