Solved

MySQL fulltext search with MATCH...AGAINST

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
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 …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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