Kouhei Sutou
null+****@clear*****
Thu Apr 19 15:55:18 JST 2018
Kouhei Sutou 2018-04-19 15:55:18 +0900 (Thu, 19 Apr 2018) New Revision: 22ae0323932bba112fd860a1864f261092bca801 https://github.com/groonga/groonga/commit/22ae0323932bba112fd860a1864f261092bca801 Message: Fix a bug that wrong scorer may be used It's caused when multiple scorers are used. Added files: test/command/suite/select/match_columns/scorer/multiple.expected test/command/suite/select/match_columns/scorer/multiple.test Modified files: lib/expr.c Modified: lib/expr.c (+3 -1) =================================================================== --- lib/expr.c 2018-04-18 10:52:30 +0900 (fbe46aaeb) +++ lib/expr.c 2018-04-19 15:55:18 +0900 (20e360f7c) @@ -6424,7 +6424,9 @@ grn_table_select_index_match(grn_ctx *ctx, optarg.scorer_args_expr_offset = GRN_UINT32_VALUE_AT(&(si->scorer_args_expr_offsets), j); if (j < n_indexes - 1) { - if (sid && ip[0] == ip[1]) { continue; } + if (sid && ip[0] == ip[1] && !optarg.scorer) { + continue; + } } grn_obj_search(ctx, ip[0], si->query, res, si->logical_op, &optarg); if (optarg.weight_vector) { Added: test/command/suite/select/match_columns/scorer/multiple.expected (+63 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/match_columns/scorer/multiple.expected 2018-04-19 15:55:18 +0900 (49811f897) @@ -0,0 +1,63 @@ +table_create Memos TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos title COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +column_create Memos content COLUMN_SCALAR Text +[[0,0.0,0.0],true] +table_create Lexicon TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto +[[0,0.0,0.0],true] +column_create Lexicon memo_index COLUMN_INDEX|WITH_POSITION|WITH_SECTION Memos title,content +[[0,0.0,0.0],true] +load --table Memos +[ +["title", "content"], +["Groonga", "Groonga"], +["Groonga Groonga", "Groonga Groonga Groonga Groonga"], +["Groonga Groonga Groonga", "Groonga"], +["Ruby Ruby Ruby", "Ruby Ruby Ruby Ruby Ruby"] +] +[[0,0.0,0.0],4] +select Memos --match_columns 'scorer_tf_at_most(title, 2.0) || scorer_tf_at_most(content, 3.0)' --query 'groonga' --output_columns "_score, title, content" --sortby -_score +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 3 + ], + [ + [ + "_score", + "Int32" + ], + [ + "title", + "ShortText" + ], + [ + "content", + "Text" + ] + ], + [ + 5, + "Groonga Groonga", + "Groonga Groonga Groonga Groonga" + ], + [ + 3, + "Groonga Groonga Groonga", + "Groonga" + ], + [ + 2, + "Groonga", + "Groonga" + ] + ] + ] +] Added: test/command/suite/select/match_columns/scorer/multiple.test (+25 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/match_columns/scorer/multiple.test 2018-04-19 15:55:18 +0900 (e8ffc2cfa) @@ -0,0 +1,25 @@ +table_create Memos TABLE_NO_KEY +column_create Memos title COLUMN_SCALAR ShortText +column_create Memos content COLUMN_SCALAR Text + +table_create Lexicon TABLE_PAT_KEY ShortText \ + --default_tokenizer TokenBigram \ + --normalizer NormalizerAuto +column_create Lexicon memo_index COLUMN_INDEX|WITH_POSITION|WITH_SECTION \ + Memos title,content + +load --table Memos +[ +["title", "content"], +["Groonga", "Groonga"], +["Groonga Groonga", "Groonga Groonga Groonga Groonga"], +["Groonga Groonga Groonga", "Groonga"], +["Ruby Ruby Ruby", "Ruby Ruby Ruby Ruby Ruby"] +] + +select Memos \ + --match_columns 'scorer_tf_at_most(title, 2.0) || \ + scorer_tf_at_most(content, 3.0)' \ + --query 'groonga' \ + --output_columns "_score, title, content" \ + --sortby -_score -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180419/3c0ce6b7/attachment-0001.htm