Solved

MySQL fulltext search with MATCH...AGAINST

Posted on 2010-09-08
3
681 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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
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 142

Accepted Solution

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

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now