Commit 8667b0a2 authored by serg@sergbook.mysql.com's avatar serg@sergbook.mysql.com
Browse files

yet another ft-trunc bug fixed

parent 3bcf1616
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
+19 −13
Original line number Diff line number Diff line
@@ -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 <word,docid>)
           |   <aaaa,row1>
           |   <aabb,row2>
           |   <aacc,row1>
           | 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 <word,docid>)
         *   <aaaa,row1>
         *   <aabb,row2>
         *   <aacc,row1>
         * 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),
+3 −0
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -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);