null+****@clear*****
null+****@clear*****
2011年 6月 18日 (土) 18:29:52 JST
Kouhei Sutou 2011-06-18 09:29:52 +0000 (Sat, 18 Jun 2011) New Revision: bde46c1bbe73c9833b32f4bcf9aa0b3ff2e15e9d Log: [wrapper][fulltext] support fulltext score. refs #1003 But order by doesn't work yet. Modified files: ha_mroonga.cc test/sql/r/fulltext_wrapper.result Modified: ha_mroonga.cc (+12 -1) =================================================================== --- ha_mroonga.cc 2011-06-18 09:20:26 +0000 (4c82414) +++ ha_mroonga.cc 2011-06-18 09:29:52 +0000 (c7cf22b) @@ -836,7 +836,18 @@ static float mrn_wrapper_ft_find_relevance(FT_INFO *handler, uchar *record, { MRN_DBUG_ENTER_FUNCTION(); st_mrn_ft_info *info = (st_mrn_ft_info *)handler; - DBUG_RETURN((float)-1.0); + + grn_obj *score_column; + score_column = grn_obj_column(info->ctx, info->result, + MRN_SCORE_COL_NAME, strlen(MRN_SCORE_COL_NAME)); + grn_obj score_value; + GRN_INT32_INIT(&score_value, 0); + grn_obj_get_value(info->ctx, score_column, info->record_id, &score_value); + float score = (float)GRN_INT32_VALUE(&score_value); + grn_obj_unlink(info->ctx, &score_value); + grn_obj_unlink(info->ctx, score_column); + + DBUG_RETURN(score); } static void mrn_wrapper_ft_close_search(FT_INFO *handler) Modified: test/sql/r/fulltext_wrapper.result (+6 -6) =================================================================== --- test/sql/r/fulltext_wrapper.result 2011-06-18 09:20:26 +0000 (38f45e3) +++ test/sql/r/fulltext_wrapper.result 2011-06-18 09:29:52 +0000 (f8a30d0) @@ -124,14 +124,14 @@ c1 c2 match(c2) against("ii") 3 aa ii ii ii oo 3 select c1,c2,match(c2) against("ii") from t1 where match(c2) against("ii"); c1 c2 match(c2) against("ii") -1 aa ii uu ee oo -1 -3 aa ii ii ii oo -1 -5 ta ti ii ii to -1 +1 aa ii uu ee oo 1 +3 aa ii ii ii oo 3 +5 ta ti ii ii to 2 select c1,c2,match(c2) against("ii") from t1 where match(c2) against("ii"); c1 c2 match(c2) against("ii") -1 aa ii uu ee oo -1 -3 aa ii ii ii oo -1 -5 ta ti ii ii to -1 +1 aa ii uu ee oo 1 +3 aa ii ii ii oo 3 +5 ta ti ii ii to 2 drop table t1,t2; create table t1 (c1 int primary key, c2 int, c3 text, fulltext index ft(c3)) COMMENT = 'engine "innodb"'; insert into t1 values(1,10,"aa ii uu ee oo");