[Groonga-commit] groonga/groonga at e0a9668 [master] Fix a bug that unexpected record is matched with space only query

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Mar 31 00:20:41 JST 2018


Kouhei Sutou	2018-03-31 00:20:41 +0900 (Sat, 31 Mar 2018)

  New Revision: e0a96680e8537aaddf104bbb7ced20024304ffc0
  https://github.com/groonga/groonga/commit/e0a96680e8537aaddf104bbb7ced20024304ffc0

  Message:
    Fix a bug that unexpected record is matched with space only query
    
    [groonga-dev,04609]
    
    Reported by satouyuzh. Thanks!!!

  Added files:
    test/command/suite/select/query/phrase_search/space.expected
    test/command/suite/select/query/phrase_search/space.test
  Modified files:
    lib/pat.c

  Modified: lib/pat.c (+4 -1)
===================================================================
--- lib/pat.c    2018-03-31 00:16:17 +0900 (8cb17876f)
+++ lib/pat.c    2018-03-31 00:20:41 +0900 (ca955af61)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2009-2017 Brazil
+  Copyright(C) 2009-2018 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -1137,6 +1137,9 @@ grn_pat_prefix_search(grn_ctx *ctx, grn_pat *pat,
   if (rc != GRN_SUCCESS) {
     return rc;
   }
+  if (key_size == 0) {
+    return GRN_END_OF_DATA;
+  }
   KEY_ENCODE(pat, keybuf, key, key_size);
   PAT_AT(pat, 0, rn);
   r = rn->lr[1];

  Added: test/command/suite/select/query/phrase_search/space.expected (+15 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query/phrase_search/space.expected    2018-03-31 00:20:41 +0900 (41b78828c)
@@ -0,0 +1,15 @@
+table_create Terms TABLE_PAT_KEY ShortText   --default_tokenizer TokenBigramSplitSymbolAlphaDigit   --normalizer NormalizerAuto
+[[0,0.0,0.0],true]
+table_create Memos TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Memos body COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"body": "'."}
+]
+[[0,0.0,0.0],1]
+column_create Terms memos_body COLUMN_INDEX|WITH_POSITION Memos body
+[[0,0.0,0.0],true]
+select Memos   --match_columns "body"   --query '" "'   --output_columns _id,_score,_key
+[[0,0.0,0.0],[[[0],[["_id","UInt32"],["_score","Int32"]]]]]

  Added: test/command/suite/select/query/phrase_search/space.test (+18 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query/phrase_search/space.test    2018-03-31 00:20:41 +0900 (6506a5e87)
@@ -0,0 +1,18 @@
+table_create Terms TABLE_PAT_KEY ShortText \
+  --default_tokenizer TokenBigramSplitSymbolAlphaDigit \
+  --normalizer NormalizerAuto
+
+table_create Memos TABLE_NO_KEY
+column_create Memos body COLUMN_SCALAR Text
+
+load --table Memos
+[
+{"body": "'."}
+]
+
+column_create Terms memos_body COLUMN_INDEX|WITH_POSITION Memos body
+
+select Memos \
+  --match_columns "body" \
+  --query '" "' \
+  --output_columns _id,_score,_key
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180331/f172cad8/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index