Solved

MySQL fulltext search with MATCH...AGAINST

Posted on 2010-09-08
3
686 Views
Last Modified: 2012-05-10
I've built a fulltext index, ft_min_word_len is set to 4,  my search returns no results for "christmas" but several results for "Christmas". I couldn't find any documentation on this. Could someone tell me what's going wrong here? I've probably left off a setting variable...


My SQL procedure is:
BEGIN
  IF inAllWords = "on" THEN
    PREPARE statement FROM
      "SELECT   pk_product, t_name,
                IF(LENGTH(t_description) <= ?,
                   t_description,
                   CONCAT(LEFT(t_description, ?),
                          '...')) AS description,
                n_price, n_discounted_price, t_thumbnail
       FROM     product
       WHERE    MATCH (t_name, t_description)
                AGAINST (? IN BOOLEAN MODE)
       ORDER BY MATCH (t_name, t_description)
                AGAINST (? IN BOOLEAN MODE) DESC
       LIMIT    ?, ?";
  ELSE
    PREPARE statement FROM
      "SELECT   pk_product, t_name,
                IF(LENGTH(t_description) <= ?,
                   t_description,
                   CONCAT(LEFT(t_description, ?),
                          '...')) AS description,
                n_price, n_discounted_price, t_thumbnail
       FROM     product
       WHERE    MATCH (t_name, t_description) AGAINST (?)
       ORDER BY MATCH (t_name, t_description) AGAINST (?) DESC
       LIMIT    ?, ?";
  END IF;

  SET @p1 = inShortProductDescriptionLength;
  SET @p2 = inSearchString;
  SET @p3 = inStartItem;
  SET @p4 = inProductsPerPage;

  EXECUTE statement USING @p1, @p1, @p2, @p2, @p3, @p4;
END

Open in new window

0
Comment
Question by:kpisor
  • 2
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33634029
what is the character set of the columns t_name and t_description?http://dev.mysql.com/doc/refman/5.1/en/fulltext-natural-language.html
By default, the search is performed in case-insensitive fashion. However, you can perform a case-sensitive full-text search by using a binary collation for the indexed columns. For example, a column that uses the latin1 character set of can be assigned a collation of latin1_bin to make it case sensitive for full-text searches. 

Open in new window

0
 

Author Comment

by:kpisor
ID: 33634065
Both t_name and t_description are varchar(100), varchar(1000), charset is UTF-8, Collation is utf8_bin. The full text index is compiled against t_name and t_description.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 33634156
>Collation is utf8_bin

so, binary... which means: case sensitive.
what you see is hence to be expected.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question