[Groonga-commit] groonga/groonga at 55e01af [master] Fix a bug that "*" with single character can't prefix search

Back to archive index

naoa null+****@clear*****
Thu Nov 13 12:02:09 JST 2014


naoa	2014-11-13 12:02:09 +0900 (Thu, 13 Nov 2014)

  New Revision: 55e01af017f8318d2f8cea849e60336eee7aaa2a
  https://github.com/groonga/groonga/commit/55e01af017f8318d2f8cea849e60336eee7aaa2a

  Merged e2f34cc: Merge pull request #243 from naoa/fix-sigle-char-prefix-search

  Message:
    Fix a bug that "*" with single character can't prefix search
    
    GitHub: fix #242

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

  Modified: lib/expr.c (+1 -1)
===================================================================
--- lib/expr.c    2014-11-11 18:56:28 +0900 (ffcce9e)
+++ lib/expr.c    2014-11-13 12:02:09 +0900 (707ccc6)
@@ -6157,7 +6157,7 @@ get_word_(grn_ctx *ctx, efs_info *q)
       GRN_INT32_PUT(ctx, &q->mode_stack, mode);
 
       return GRN_SUCCESS;
-    } else if (GRN_TEXT_LEN(&q->buf) > 1 && *end == GRN_QUERY_PREFIX) {
+    } else if (GRN_TEXT_LEN(&q->buf) > 0 && *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/with_single_character.expected (+63 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query/asterisk/with_single_character.expected    2014-11-13 12:02:09 +0900 (8942661)
@@ -0,0 +1,63 @@
+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."}
+]
+[[0,0.0,0.0],6]
+select   --table Diaries   --match_columns content   --query "t*"   --output_columns content,_score   --sortby _id
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        5
+      ],
+      [
+        [
+          "content",
+          "ShortText"
+        ],
+        [
+          "_score",
+          "Int32"
+        ]
+      ],
+      [
+        "It'll be fine tomorrow as well.",
+        1
+      ],
+      [
+        "It'll rain tomorrow.",
+        1
+      ],
+      [
+        "It's fine today. It'll be fine tomorrow as well.",
+        2
+      ],
+      [
+        "It's fine today. But it'll rain tomorrow.",
+        2
+      ],
+      [
+        "Ring the bell.",
+        1
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/query/asterisk/with_single_character.test (+24 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/query/asterisk/with_single_character.test    2014-11-13 12:02:09 +0900 (0ffb413)
@@ -0,0 +1,24 @@
+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."}
+]
+
+select \
+  --table Diaries \
+  --match_columns content \
+  --query "t*" \
+  --output_columns content,_score \
+  --sortby _id
-------------- next part --------------
HTML����������������������������...
Download 



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