Kouhei Sutou
null+****@clear*****
Fri Mar 24 14:21:46 JST 2017
Kouhei Sutou 2017-03-24 14:21:46 +0900 (Fri, 24 Mar 2017) New Revision: 30627a4baa6853a2507b1be90a71c50ec294eeae https://github.com/groonga/groonga/commit/30627a4baa6853a2507b1be90a71c50ec294eeae Message: select: fix a bug that "A && B.C @ X" may not return records that should be matched See the test included in this change for details. Without this change, the select returns no records. Added files: test/command/suite/select/filter/index/optimization/and_min_skip/nested_index.expected test/command/suite/select/filter/index/optimization/and_min_skip/nested_index.test Modified files: lib/db.c Modified: lib/db.c (+3 -0) =================================================================== --- lib/db.c 2017-03-24 14:21:21 +0900 (cef49af) +++ lib/db.c 2017-03-24 14:21:46 +0900 (6743f1c) @@ -3508,6 +3508,9 @@ grn_obj_search_accessor(grn_ctx *ctx, grn_obj *obj, grn_obj *query, if (!base_res) { goto exit; } + if (optarg) { + optarg->match_info.min = GRN_ID_NIL; + } rc = grn_obj_search(ctx, index, query, base_res, GRN_OP_OR, optarg); if (rc != GRN_SUCCESS) { grn_obj_unlink(ctx, base_res); Added: test/command/suite/select/filter/index/optimization/and_min_skip/nested_index.expected (+60 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/filter/index/optimization/and_min_skip/nested_index.expected 2017-03-24 14:21:46 +0900 (1df1598) @@ -0,0 +1,60 @@ +table_create Tags TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +table_create Memos TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos user COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +column_create Memos tag COLUMN_SCALAR Tags +[[0,0.0,0.0],true] +column_create Tags memos_tag COLUMN_INDEX Memos tag +[[0,0.0,0.0],true] +table_create UserTerms TABLE_PAT_KEY ShortText --normalize NormalizerAuto --default_tokenizer TokenBigram +[[0,0.0,0.0],true] +column_create UserTerms memos_user COLUMN_INDEX|WITH_POSITION Memos user +[[0,0.0,0.0],true] +table_create TagTerms TABLE_PAT_KEY ShortText --normalize NormalizerAuto --default_tokenizer TokenBigram +[[0,0.0,0.0],true] +column_create TagTerms tags_key COLUMN_INDEX|WITH_POSITION Tags _key +[[0,0.0,0.0],true] +load --table Memos +[ +{"user": "Alice", "tag": "B"}, +{"user": "Alice", "tag": "A"}, +{"user": "Alice", "tag": "B"}, +{"user": "Bob", "tag": "A"} +] +[[0,0.0,0.0],4] +select Memos --match_escalation_threshold -1 --filter 'user @ "Bob" && tag._key @ "A"' +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 1 + ], + [ + [ + "_id", + "UInt32" + ], + [ + "tag", + "Tags" + ], + [ + "user", + "ShortText" + ] + ], + [ + 4, + "A", + "Bob" + ] + ] + ] +] Added: test/command/suite/select/filter/index/optimization/and_min_skip/nested_index.test (+29 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/filter/index/optimization/and_min_skip/nested_index.test 2017-03-24 14:21:46 +0900 (e3fd2d1) @@ -0,0 +1,29 @@ +table_create Tags TABLE_HASH_KEY ShortText + +table_create Memos TABLE_NO_KEY +column_create Memos user COLUMN_SCALAR ShortText +column_create Memos tag COLUMN_SCALAR Tags + +column_create Tags memos_tag COLUMN_INDEX Memos tag + +table_create UserTerms TABLE_PAT_KEY ShortText \ + --normalize NormalizerAuto \ + --default_tokenizer TokenBigram +column_create UserTerms memos_user COLUMN_INDEX|WITH_POSITION Memos user + +table_create TagTerms TABLE_PAT_KEY ShortText \ + --normalize NormalizerAuto \ + --default_tokenizer TokenBigram +column_create TagTerms tags_key COLUMN_INDEX|WITH_POSITION Tags _key + +load --table Memos +[ +{"user": "Alice", "tag": "B"}, +{"user": "Alice", "tag": "A"}, +{"user": "Alice", "tag": "B"}, +{"user": "Bob", "tag": "A"} +] + +select Memos \ + --match_escalation_threshold -1 \ + --filter 'user @ "Bob" && tag._key @ "A"' -------------- next part -------------- HTML����������������������������...Download