Kouhei Sutou
null+****@clear*****
Mon Feb 24 14:38:22 JST 2014
Kouhei Sutou 2014-02-24 14:38:22 +0900 (Mon, 24 Feb 2014) New Revision: 4ccec574b5d00f2ce0af1523161303c368e2736d https://github.com/groonga/groonga/commit/4ccec574b5d00f2ce0af1523161303c368e2736d Message: Support weight by forward index feature by nested inded Added files: test/command/suite/select/match_columns/weight/nested_forward_index.expected test/command/suite/select/match_columns/weight/nested_forward_index.test Modified files: lib/db.c Modified: lib/db.c (+2 -2) =================================================================== --- lib/db.c 2014-02-24 13:15:09 +0900 (f59d780) +++ lib/db.c 2014-02-24 14:38:22 +0900 (4384bf0) @@ -2791,7 +2791,7 @@ grn_obj_search_accessor(grn_ctx *ctx, grn_obj *obj, grn_obj *query, if (!base_res) { goto exit; } - rc = grn_obj_search(ctx, index, query, base_res, GRN_OP_OR, optarg); + rc = grn_obj_search(ctx, last_obj, query, base_res, GRN_OP_OR, optarg); if (rc != GRN_SUCCESS) { grn_obj_unlink(ctx, base_res); goto exit; @@ -9333,7 +9333,7 @@ grn_column_index_accessor(grn_ctx *ctx, grn_obj *obj, grn_operator op, grn_hook_entry entry = -1; if (a->action == GRN_ACCESSOR_GET_COLUMN_VALUE && - a->obj->header.type == GRN_COLUMN_INDEX) { + GRN_OBJ_INVERTED_INDEX_COLUMNP(a->obj)) { return grn_column_index_accessor_index_column(ctx, a, op, indexbuf, buf_size, section); } Added: test/command/suite/select/match_columns/weight/nested_forward_index.expected (+112 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/match_columns/weight/nested_forward_index.expected 2014-02-24 14:38:22 +0900 (74851a1) @@ -0,0 +1,112 @@ +table_create Tags TABLE_PAT_KEY ShortText +[[0,0.0,0.0],true] +table_create Products TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Products tags COLUMN_INDEX|WITH_WEIGHT Tags +[[0,0.0,0.0],true] +column_create Tags products_tags COLUMN_INDEX Products tags +[[0,0.0,0.0],true] +table_create Programmers TABLE_PAT_KEY ShortText +[[0,0.0,0.0],true] +column_create Programmers products COLUMN_VECTOR Products +[[0,0.0,0.0],true] +column_create Products programmers_products COLUMN_INDEX Programmers products +[[0,0.0,0.0],true] +load --table Products +[ +{ + "_key": "Groonga", + "tags": { + "groonga": 100 + } +}, +{ + "_key": "Mroonga", + "tags": { + "mroonga": 100, + "groonga": 50 + } +}, +{ + "_key": "Rroonga", + "tags": { + "ruby": 100, + "groonga": 10 + } +}, +{ + "_key": "TST", + "tags": { + "mozilla": 100 + } +} +] +[[0,0.0,0.0],4] +load --table Programmers +[ +{ + "_key": "daijiro", + "products": [ + "Groonga", + "Mroonga" + ] +}, +{ + "_key": "kou", + "products": [ + "Groonga", + "Mroonga", + "Rroonga" + ] +}, +{ + "_key": "maruyama", + "products": [ + "Mroonga" + ] +}, +{ + "_key": "piro", + "products": [ + "TST" + ] +} +] +[[0,0.0,0.0],4] +select Programmers --match_columns 'products.tags * 10' --query groonga --output_columns _key,_score +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 3 + ], + [ + [ + "_key", + "ShortText" + ], + [ + "_score", + "Int32" + ] + ], + [ + "daijiro", + 1500 + ], + [ + "kou", + 1600 + ], + [ + "maruyama", + 500 + ] + ] + ] +] Added: test/command/suite/select/match_columns/weight/nested_forward_index.test (+78 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/match_columns/weight/nested_forward_index.test 2014-02-24 14:38:22 +0900 (fe36617) @@ -0,0 +1,78 @@ +table_create Tags TABLE_PAT_KEY ShortText + +table_create Products TABLE_HASH_KEY ShortText +column_create Products tags COLUMN_INDEX|WITH_WEIGHT Tags + +column_create Tags products_tags COLUMN_INDEX Products tags + +table_create Programmers TABLE_PAT_KEY ShortText +column_create Programmers products COLUMN_VECTOR Products + +column_create Products programmers_products COLUMN_INDEX Programmers products + +load --table Products +[ +{ + "_key": "Groonga", + "tags": { + "groonga": 100 + } +}, +{ + "_key": "Mroonga", + "tags": { + "mroonga": 100, + "groonga": 50 + } +}, +{ + "_key": "Rroonga", + "tags": { + "ruby": 100, + "groonga": 10 + } +}, +{ + "_key": "TST", + "tags": { + "mozilla": 100 + } +} +] + +load --table Programmers +[ +{ + "_key": "daijiro", + "products": [ + "Groonga", + "Mroonga" + ] +}, +{ + "_key": "kou", + "products": [ + "Groonga", + "Mroonga", + "Rroonga" + ] +}, +{ + "_key": "maruyama", + "products": [ + "Mroonga" + ] +}, +{ + "_key": "piro", + "products": [ + "TST" + ] +} +] + + +select Programmers \ + --match_columns 'products.tags * 10' \ + --query groonga \ + --output_columns _key,_score -------------- next part -------------- HTML����������������������������...Download