naoa
null+****@clear*****
Fri Feb 5 13:46:10 JST 2016
naoa 2016-02-05 13:46:10 +0900 (Fri, 05 Feb 2016) New Revision: 795a1289a9611f83874efc25d23db5c5b74d1ef9 https://github.com/groonga/groonga/commit/795a1289a9611f83874efc25d23db5c5b74d1ef9 Merged a300aa1: Merge pull request #464 from naoa/master Message: Check whether lexicon is GRN_TABLE_PAT_KEY or not Added files: test/command/suite/select/function/fuzzy_search/index/hash.expected test/command/suite/select/function/fuzzy_search/index/hash.test Modified files: lib/proc.c Modified: lib/proc.c (+15 -7) =================================================================== --- lib/proc.c 2016-02-05 13:27:07 +0900 (74d7369) +++ lib/proc.c 2016-02-05 13:46:10 +0900 (ecf7edf) @@ -7056,15 +7056,23 @@ selector_fuzzy_search(grn_ctx *ctx, grn_obj *table, grn_obj *index, } else { grn_column_index(ctx, obj, GRN_OP_FUZZY, &target, 1, NULL); } - if (!target) { - if (grn_obj_is_key_accessor(ctx, obj) && - table->header.type == GRN_TABLE_PAT_KEY) { - target = table; - } else { - use_sequential_search = GRN_TRUE; - } + } + + if (target) { + grn_obj *lexicon; + lexicon = grn_ctx_at(ctx, target->header.domain); + if (lexicon->header.type != GRN_TABLE_PAT_KEY) { + use_sequential_search = GRN_TRUE; + } + } else { + if (grn_obj_is_key_accessor(ctx, obj) && + table->header.type == GRN_TABLE_PAT_KEY) { + target = table; + } else { + use_sequential_search = GRN_TRUE; } } + if (prefix_length) { const char *s = GRN_TEXT_VALUE(query); const char *e = GRN_BULK_CURR(query); Added: test/command/suite/select/function/fuzzy_search/index/hash.expected (+48 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/function/fuzzy_search/index/hash.expected 2016-02-05 13:46:10 +0900 (76346a2) @@ -0,0 +1,48 @@ +table_create Users TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Users name COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +table_create Tags TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Tags tag COLUMN_INDEX Users name +[[0,0.0,0.0],true] +load --table Users +[ +{"name": "Tom"}, +{"name": "Tomy"}, +{"name": "Ken"} +] +[[0,0.0,0.0],3] +select Users --filter 'fuzzy_search(name, "Tom", 1)' --output_columns 'name, _score' --match_escalation_threshold -1 +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 2 + ], + [ + [ + "name", + "ShortText" + ], + [ + "_score", + "Int32" + ] + ], + [ + "Tom", + 0 + ], + [ + "Tomy", + 1 + ] + ] + ] +] Added: test/command/suite/select/function/fuzzy_search/index/hash.test (+16 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/function/fuzzy_search/index/hash.test 2016-02-05 13:46:10 +0900 (29ba7a5) @@ -0,0 +1,16 @@ +table_create Users TABLE_NO_KEY +column_create Users name COLUMN_SCALAR ShortText + +table_create Tags TABLE_HASH_KEY ShortText +column_create Tags tag COLUMN_INDEX Users name + +load --table Users +[ +{"name": "Tom"}, +{"name": "Tomy"}, +{"name": "Ken"} +] + +select Users --filter 'fuzzy_search(name, "Tom", 1)' \ + --output_columns 'name, _score' \ + --match_escalation_threshold -1 -------------- next part -------------- HTML����������������������������... 下载