Navigation Menu

Skip to content

Commit

Permalink
[wrapper][fulltext] support fulltext score. refs #1003
Browse files Browse the repository at this point in the history
But order by doesn't work yet.
  • Loading branch information
kou committed Jun 18, 2011
1 parent fd3e9eb commit bde46c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
13 changes: 12 additions & 1 deletion ha_mroonga.cc
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions test/sql/r/fulltext_wrapper.result
Expand Up @@ -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");
Expand Down

0 comments on commit bde46c1

Please sign in to comment.