Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MySQL fulltext search with MATCH...AGAINST

Posted on 2010-09-08
3
Medium Priority
?
691 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 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