Open regstuff opened 2 years ago
mysql> drop table if exists t; create table t (f text); insert into t(f) values('word2 smth smth word1 smth word2 smth word3'); select highlight() from t where match('word1 NEAR/2 word2 NEAR/2 word3'); select highlight() from t where match('word1 NEAR/3 word2 NEAR/2 word3');
--------------
drop table if exists t
--------------
Query OK, 0 rows affected (0.02 sec)
--------------
create table t (f text)
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
insert into t(f) values('word2 smth smth word1 smth word2 smth word3')
--------------
Query OK, 1 row affected (0.00 sec)
--------------
select highlight() from t where match('word1 NEAR/2 word2 NEAR/2 word3')
--------------
+------------------------------------------------------------------+
| highlight() |
+------------------------------------------------------------------+
| word2 smth smth <b>word1</b> smth <b>word2</b> smth <b>word3</b> |
+------------------------------------------------------------------+
1 row in set (0.00 sec)
--------------
select highlight() from t where match('word1 NEAR/3 word2 NEAR/2 word3')
--------------
Empty set (0.00 sec)
Describe the bug
Consider the sentence: word2 something something word1 something word2 something word3
A search such as word1 NEAR/2 word2 NEAR/2 word3 will result in a match with the sentence
Similarly, word1 NEAR/3 word2 NEAR/3 word3 will also result in a match
word1 NEAR/3 word2 NEAR/2 word3 should also match this sentence but it does not.
A sentence without the first word2, such as: something something word1 something word2 something word3
will work for all the above proximity searches.
Search fails when two conditions are met:
MRE
Below python code creates the sentence and runs the 3 searches mentioned above. First search fails where as the rest work.