From 19eb09ae8a43ee910533acdfdc6985d3601fbf5a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 May 2002 20:31:24 +0200 Subject: [PATCH] yet another ft-trunc bug fixed --- Docs/manual.texi | 3 +++ myisam/ft_boolean_search.c | 32 +++++++++++++++++++------------- mysql-test/r/fulltext.result | 3 +++ mysql-test/t/fulltext.test | 2 ++ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 72304926e38..8dfb6cb79be 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -49211,6 +49211,9 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. @itemize @bullet @item +Fixed bug in truncation operator of boolean fulltext search (wrong results +when there are only @code{+word*}'s in the query). +@item Fixed bug in phrase operator @code{"..."} in boolean full-text search. @item Fixed bug that caused duplicated rows when using truncation operator diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index f78d2e3c05f..1b44f9d1ab9 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -200,25 +200,31 @@ void _ftb_init_index_search(FT_INFO *ftb) { ftbw=(FTB_WORD *)(ftb->queue.root[i]); - if (ftbw->flags&FTB_FLAG_TRUNC) /* special treatment :(( */ - if (ftbw->up->ythresh > test(ftbw->flags&FTB_FLAG_YES)) + if (ftbw->flags&FTB_FLAG_TRUNC) + /* special treatment for truncation operator :(( + 1. +trunc* and there're other (not +trunc*) words + | no need to search in the index, it can never ADD new rows + | to the result, and to remove half-matched rows we do scan anyway + 2. -trunc* + | same as 1. + 3. trunc* + | We have to index-search for this prefix. + | It may cause duplicates, as in the index (sorted by ) + | + | + | + | Searching for "aa*" will find row1 twice... + */ + if ( test(ftbw->flags&FTB_FLAG_NO) || /* 2 */ + (test(ftbw->flags&FTB_FLAG_YES) && /* 1 */ + ftbw->up->ythresh - ftbw->up->yweaks >1)) /* 1 */ { - /* no need to search for this prefix in the index - - * it cannot ADD new matches, and to REMOVE half-matched - * rows we do scan anyway */ ftbw->docid[0]=HA_POS_ERROR; ftbw->up->yweaks++; continue; } - else + else /* 3 */ { - /* We have to index-search for this prefix. - * It may cause duplicates, as in the index (sorted by ) - * - * - * - * Searching for "aa*" will find row1 twice... - */ if (!is_tree_inited(& ftb->no_dupes)) { init_tree(& ftb->no_dupes,0,0,sizeof(my_off_t), diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 7344997bd1b..5ecab7278db 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -67,6 +67,9 @@ Full-text indexes are called collections 1 Only MyISAM tables support collections 2 Function MATCH ... AGAINST() is used to do a search 0 Full-text search in MySQL implements vector space model 0 +select * from t1 where MATCH a,b AGAINST ("+call* +coll*" IN BOOLEAN MODE); +a b +Full-text indexes are called collections select * from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE); a b MySQL has now support for full-text search diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index f9ecde1d6e2..238705c8e3e 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -33,6 +33,8 @@ select * from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN select *, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; select *, MATCH(a,b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +select * from t1 where MATCH a,b AGAINST ("+call* +coll*" IN BOOLEAN MODE); + select * from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('"text search" "now support"' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('"text search" -"now support"' IN BOOLEAN MODE);