1

I am using full text search the query is having single quote in where clause it returning values but not accurate.

SELECT `id`, `itemid`, `title`, 
MATCH( `itemid`, `title`, `product_id`,`p1_name`, `p2_name`, `p3_name`, `p4_name` ) 
AGAINST ( "men\'s" IN BOOLEAN MODE ) AS score FROM `deals` 
WHERE `active_flag`='1' AND 
MATCH( `itemid`, `title`, `product_id`,`p1_name`, `p2_name`, `p3_name`, `p4_name`) 
AGAINST ( "men\'s" IN BOOLEAN MODE ) !=0 
ORDER BY score DESC

it should return the case where key word is exactly "Men's" (dont include " double quotes). but it is returning the cases where men and s exist?

can anybody help me out?

thanks.

Mad Dog Tannen
  • 7,129
  • 5
  • 31
  • 55
Manish Malviya
  • 861
  • 2
  • 13
  • 19

2 Answers2

0

Its most likley because of the internal stopword list for MyISAM fulltext.

According to this documentation

The variable value should be the path name of the file containing the stopword list, or the empty string to disable stopword filtering. The server looks for the file in the data directory unless an absolute path name is given to specify a different directory. After changing the value of this variable or the contents of the stopword file, restart the server and rebuild your FULLTEXT indexes.

I changed in my ini file this

+ft_stopword_file = C:\ProgramData\MySQL\MySQL Server 5.6/mysql_ft_stopword_file.txt

Then restart the server, it will start even if the file doesnt exists so you dont have to create one. You will have to rebuild the table after the restart.

I now managed to get results using this query

SELECT * FROM test.fttest 
WHERE MATCH(txt) AGAINST("men's" IN BOOLEAN MODE);

and this also

SELECT * FROM test.fttest 
WHERE MATCH(txt) AGAINST('men\'s' IN BOOLEAN MODE);

It may be a good idea to later build your own stopword list if you have alot of data since no words are considered as stopwords so the indexes will get bigger.

Mad Dog Tannen
  • 7,129
  • 5
  • 31
  • 55
-1

Escape a ' with two of them ''

  where name = 'men''s'
DavidC
  • 1,842
  • 1
  • 18
  • 32
  • 4
    Yes, but that's mysql being compatible with other systems. Normal escaping is a backslash, and changing `men\'s` to `men''s` will NOT fix the problem. it's just reordering the deckchairs on the titanic. – Marc B Dec 19 '13 at 15:06