Bug #35359 ~ is not working correctly. Its behaving like - in fulltext boolean searches
Submitted: 18 Mar 2008 5:48 Modified: 21 Mar 2008 12:01
Reporter: Rizwan Maredia Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: FULLTEXT search Severity:S3 (Non-critical)
Version:5.1.22 OS:Windows
Assigned to: Sergey Vojtovich CPU Architecture:Any
Tags: ~, ft_boolean_syntax

[18 Mar 2008 5:48] Rizwan Maredia
Description:
~ is not working correctly sometimes. It is behaving like – in Full text searching in Boolean mode. ~ should just decrease the relevance and not totally remove the row from result.

How to repeat:
Here is how we can produce this bug

Sample Code: 
CREATE TABLE articles (
   id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
   title VARCHAR(200),
   body TEXT,
   FULLTEXT (title,body)
);

INSERT INTO articles (title,body) VALUES
('Optimizing MySQL','In this tutorial we will show .... Run command line ...'),
('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...');

SELECT * FROM articles WHERE MATCH (title,body)
AGAINST ('+run ~line' IN BOOLEAN MODE);

Output:
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
title VARCHAR(200),
body TEXT,
FULLTEXT (title,body)
);
INSERT INTO articles (title,body) VALUES
('Optimizing MySQL','In this tutorial we will show .... Run command line ...'),
('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...');
SELECT * FROM articles WHERE MATCH (title,body)
AGAINST ('+run ~line' IN BOOLEAN MODE);
id	title	body

Suggested fix:
Since 'run' and 'line' are not Stop Words it should return all rows.
[19 Mar 2008 19:34] Susanne Ebrecht
Many thanks for writing a bug report.

Verified as described with 5.1-bk.
[21 Mar 2008 12:01] Sergey Vojtovich
'run' is not a stopword, but it is too shorter than ft_min_word_len. You should decrease ft_min_word_len to make searches for short words possible. For example searching for '+mysql ~line' works fine.