[Groonga-commit] groonga/groonga at 4084aee [master] Fix a bug that "*" is parsed as prefix search with empty string

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Sep 25 20:56:46 JST 2014


Kouhei Sutou	2014-09-25 20:56:46 +0900 (Thu, 25 Sep 2014)

  New Revision: 4084aee6efac2f823182ce28018355070762454f
  https://github.com/groonga/groonga/commit/4084aee6efac2f823182ce28018355070762454f

  Message:
    Fix a bug that "*" is parsed as prefix search with empty string
    
    [groonga-dev,02796]
    
    Reported by Kazuhiko. Thanks!!!

  Added files:
    test/command/suite/select/query/asterisk/only.expected
    test/command/suite/select/query/asterisk/only.test
  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+1 -1)
===================================================================
--- lib/expr.c    2014-09-25 20:50:00 +0900 (771f9bf)
+++ lib/expr.c    2014-09-25 20:56:46 +0900 (e899859)
@@ -6034,7 +6034,7 @@ get_word_(grn_ctx *ctx, efs_info *q)
       GRN_INT32_PUT(ctx, &q->mode_stack, mode);
 
       return GRN_SUCCESS;
-    } else if (*end == GRN_QUERY_PREFIX) {
+    } else if (len > 1 && *end == GRN_QUERY_PREFIX) {
       q->cur = end + 1;
       GRN_INT32_PUT(ctx, &q->mode_stack, GRN_OP_PREFIX);
       break;

  Added: test/command/suite/select/query/asterisk/only.expected (+48 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query/asterisk/only.expected    2014-09-25 20:56:46 +0900 (989fe2a)
@@ -0,0 +1,48 @@
+table_create Diaries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Diaries content COLUMN_SCALAR ShortText
+[[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 diaries_content COLUMN_INDEX|WITH_POSITION Diaries content
+[[0,0.0,0.0],true]
+load --table Diaries
+[
+{"content": "It'll be fine tomorrow as well."},
+{"content": "It'll rain tomorrow."},
+{"content": "It's fine today. It'll be fine tomorrow as well."},
+{"content": "It's fine today. But it'll rain tomorrow."},
+{"content": "Ring the bell."},
+{"content": "I love dumbbells."},
+{"content": "It's *important*!"}
+]
+[[0,0.0,0.0],7]
+select   --table Diaries   --match_columns content   --query "*"   --output_columns content,_score   --sortby _id
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "content",
+          "ShortText"
+        ],
+        [
+          "_score",
+          "Int32"
+        ]
+      ],
+      [
+        "It's *important*!",
+        1
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/query/asterisk/only.test (+25 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query/asterisk/only.test    2014-09-25 20:56:46 +0900 (48fd5a0)
@@ -0,0 +1,25 @@
+table_create Diaries TABLE_NO_KEY
+column_create Diaries content COLUMN_SCALAR ShortText
+
+table_create Terms TABLE_PAT_KEY ShortText \
+  --default_tokenizer TokenBigram \
+  --normalizer NormalizerAuto
+column_create Terms diaries_content COLUMN_INDEX|WITH_POSITION Diaries content
+
+load --table Diaries
+[
+{"content": "It'll be fine tomorrow as well."},
+{"content": "It'll rain tomorrow."},
+{"content": "It's fine today. It'll be fine tomorrow as well."},
+{"content": "It's fine today. But it'll rain tomorrow."},
+{"content": "Ring the bell."},
+{"content": "I love dumbbells."},
+{"content": "It's *important*!"}
+]
+
+select \
+  --table Diaries \
+  --match_columns content \
+  --query "*" \
+  --output_columns content,_score \
+  --sortby _id
-------------- next part --------------
HTML����������������������������...
Download 



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