Kouhei Sutou
null+****@clear*****
Wed Nov 5 11:44:20 JST 2014
Kouhei Sutou 2014-11-05 11:44:20 +0900 (Wed, 05 Nov 2014) New Revision: dab77b8e50ab233158865827bfd0072b5a587f30 https://github.com/groonga/groonga/commit/dab77b8e50ab233158865827bfd0072b5a587f30 Message: Fix a bug that nested indexed full text search against _key See the added test case for details. Added files: test/command/suite/select/index/nested/by_key/match.expected test/command/suite/select/index/nested/by_key/match.test Modified files: lib/db.c Modified: lib/db.c (+14 -1) =================================================================== --- lib/db.c 2014-11-05 11:19:09 +0900 (c7f09f0) +++ lib/db.c 2014-11-05 11:44:20 +0900 (5bccf2c) @@ -9593,9 +9593,22 @@ grn_column_index_column_match(grn_ctx *ctx, grn_obj *obj, grn_operator op, { int n = 0; grn_obj **ip = indexbuf; + grn_hook_entry hook_entry; grn_hook *hooks; - for (hooks = DB_OBJ(obj)->hooks[GRN_HOOK_SET]; hooks; hooks = hooks->next) { + switch (obj->header.type) { + case GRN_TABLE_HASH_KEY : + case GRN_TABLE_PAT_KEY : + case GRN_TABLE_DAT_KEY : + case GRN_TABLE_NO_KEY : + hook_entry = GRN_HOOK_INSERT; + break; + default : + hook_entry = GRN_HOOK_SET; + break; + } + + for (hooks = DB_OBJ(obj)->hooks[hook_entry]; hooks; hooks = hooks->next) { default_set_value_hook_data *data = (void *)NEXT_ADDR(hooks); grn_obj *target = grn_ctx_at(ctx, data->target); if (target->header.type != GRN_COLUMN_INDEX) { continue; } Added: test/command/suite/select/index/nested/by_key/match.expected (+23 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/index/nested/by_key/match.expected 2014-11-05 11:44:20 +0900 (fb0451f) @@ -0,0 +1,23 @@ +table_create Paths TABLE_PAT_KEY ShortText +[[0,0.0,0.0],true] +table_create Logs TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs message COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +column_create Logs path COLUMN_SCALAR Paths +[[0,0.0,0.0],true] +column_create Paths logs_index COLUMN_INDEX Logs path +[[0,0.0,0.0],true] +table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto +[[0,0.0,0.0],true] +column_create Terms path_index COLUMN_INDEX|WITH_POSITION Paths _key +[[0,0.0,0.0],true] +load --table Logs +[ +{"message": "access", "path": "/home/alice/.zshrc"}, +{"message": "write", "path": "/home/bob/.bashrc"}, +{"message": "read", "path": "/home/calros/public_html/index.html"} +] +[[0,0.0,0.0],3] +select Logs --filter 'path._key @ "alice"' --output_columns '_key, path' +[[0,0.0,0.0],[[[1],[["path","Paths"]],["/home/alice/.zshrc"]]]] Added: test/command/suite/select/index/nested/by_key/match.test (+23 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/index/nested/by_key/match.test 2014-11-05 11:44:20 +0900 (4086817) @@ -0,0 +1,23 @@ +table_create Paths TABLE_PAT_KEY ShortText + +table_create Logs TABLE_NO_KEY +column_create Logs message COLUMN_SCALAR ShortText +column_create Logs path COLUMN_SCALAR Paths + +column_create Paths logs_index COLUMN_INDEX Logs path + +table_create Terms TABLE_PAT_KEY ShortText \ + --default_tokenizer TokenBigram \ + --normalizer NormalizerAuto +column_create Terms path_index COLUMN_INDEX|WITH_POSITION Paths _key + +load --table Logs +[ +{"message": "access", "path": "/home/alice/.zshrc"}, +{"message": "write", "path": "/home/bob/.bashrc"}, +{"message": "read", "path": "/home/calros/public_html/index.html"} +] + +select Logs \ + --filter 'path._key @ "alice"' \ + --output_columns '_key, path' -------------- next part -------------- HTML����������������������������...Download