Solved

MySQL fulltext search with MATCH...AGAINST

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mySql Syntax 7 44
how do i form the query to get different columns total count 13 42
Instering to MySQL table 5 37
update joined tables 2 26
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
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 …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 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

6 Experts available now in Live!

Get 1:1 Help Now