Kouhei Sutou
null+****@clear*****
Wed Apr 12 17:08:11 JST 2017
Kouhei Sutou 2017-04-12 17:08:11 +0900 (Wed, 12 Apr 2017) New Revision: fc89271109ab350730e73b794bb6417edcabed6a https://github.com/groonga/groonga/commit/fc89271109ab350730e73b794bb6417edcabed6a Message: ii regexp: support multiple matches case Added files: test/command/suite/select/filter/index/regexp/dot_asterisk/n_matches.expected test/command/suite/select/filter/index/regexp/dot_asterisk/n_matches.test Modified files: lib/ii.c Modified: lib/ii.c (+6 -2) =================================================================== --- lib/ii.c 2017-04-12 16:45:10 +0900 (701174f) +++ lib/ii.c 2017-04-12 17:08:11 +0900 (344c7c4) @@ -7974,8 +7974,10 @@ grn_ii_select_cursor_next(grn_ctx *ctx, cursor->posting.pos = pos; cursor->posting.tf = n_occurs; cursor->posting.weight = tscore; - if (token_info_skip(ctx, *tis, next_rid, next_sid) != GRN_SUCCESS) { - cursor->done = GRN_TRUE; + if (token_info_skip_pos(ctx, *tis, rid, sid, pos + 1) != GRN_SUCCESS) { + if (token_info_skip(ctx, *tis, next_rid, next_sid) != GRN_SUCCESS) { + cursor->done = GRN_TRUE; + } } return &(cursor->posting); } @@ -8168,6 +8170,8 @@ grn_ii_select_regexp(grn_ctx *ctx, grn_ii *ii, if (posting_i->rid == posting->rid && posting_i->sid == posting->sid && posting_i->pos > pos) { + keep_i = i; + keep_posting = *posting_i; break; } if (posting_i->rid > posting->rid) { Added: test/command/suite/select/filter/index/regexp/dot_asterisk/n_matches.expected (+62 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/filter/index/regexp/dot_asterisk/n_matches.expected 2017-04-12 17:08:11 +0900 (088ec2f) @@ -0,0 +1,62 @@ +table_create Memos TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos content COLUMN_SCALAR Text +[[0,0.0,0.0],true] +table_create RegexpTokens TABLE_PAT_KEY ShortText --normalizer NormalizerAuto --default_tokenizer TokenRegexp +[[0,0.0,0.0],true] +column_create RegexpTokens memos_content COLUMN_INDEX|WITH_POSITION Memos content +[[0,0.0,0.0],true] +load --table Memos +[ +{"content": "Groonga Groonga"}, +{"content": "Groonga Rroonga"}, +{"content": "PGroonga PostgreSQL"} +] +[[0,0.0,0.0],3] +log_level --level info +[[0,0.0,0.0],true] +select Memos --filter 'content @~ "g.*ga"' --output_columns content,_score +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 3 + ], + [ + [ + "content", + "Text" + ], + [ + "_score", + "Int32" + ] + ], + [ + "Groonga Groonga", + 3 + ], + [ + "Groonga Rroonga", + 2 + ], + [ + "PGroonga PostgreSQL", + 1 + ] + ] + ] +] +#|i| [object][search][index][key][regexp] <RegexpTokens.memos_content> +#|i| grn_ii_sel > (g.*ga) +#|i| [ii][select][cursor][open] n=1 <g> +#|i| [ii][select][cursor][open] n=1 <ga> +#|i| exact: 3 +#|i| hits=3 +log_level --level notice +[[0,0.0,0.0],true] Added: test/command/suite/select/filter/index/regexp/dot_asterisk/n_matches.test (+25 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/filter/index/regexp/dot_asterisk/n_matches.test 2017-04-12 17:08:11 +0900 (589db0a) @@ -0,0 +1,25 @@ +#$GRN_II_REGEXP_DOT_ASTERISK_ENABLE=yes + +table_create Memos TABLE_NO_KEY +column_create Memos content COLUMN_SCALAR Text + +table_create RegexpTokens TABLE_PAT_KEY ShortText \ + --normalizer NormalizerAuto \ + --default_tokenizer TokenRegexp +column_create RegexpTokens memos_content COLUMN_INDEX|WITH_POSITION \ + Memos content + +load --table Memos +[ +{"content": "Groonga Groonga"}, +{"content": "Groonga Rroonga"}, +{"content": "PGroonga PostgreSQL"} +] + +log_level --level info +#@add-important-log-levels info +select Memos \ + --filter 'content @~ "g.*ga"' \ + --output_columns content,_score +#@remove-important-log-levels info +log_level --level notice -------------- next part -------------- HTML����������������������������... Télécharger