[Groonga-commit] groonga/groonga at 2e98b7e [master] scorer_tf_at_most: fix a bug that cast of max value doesn't work

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Mar 25 18:34:04 JST 2015


Kouhei Sutou	2015-03-25 18:34:04 +0900 (Wed, 25 Mar 2015)

  New Revision: 2e98b7e3f01255e86be4d2d604b40cf1e6b57991
  https://github.com/groonga/groonga/commit/2e98b7e3f01255e86be4d2d604b40cf1e6b57991

  Message:
    scorer_tf_at_most: fix a bug that cast of max value doesn't work

  Added files:
    test/command/suite/select/match_columns/scorer/tf_at_most/max/int32.expected
    test/command/suite/select/match_columns/scorer/tf_at_most/max/int32.test
  Modified files:
    lib/scorers.c

  Modified: lib/scorers.c (+1 -1)
===================================================================
--- lib/scorers.c    2015-03-25 17:23:43 +0900 (9ddf5a6)
+++ lib/scorers.c    2015-03-25 18:34:04 +0900 (dcec87c)
@@ -75,7 +75,7 @@ scorer_tf_at_most(grn_ctx *ctx, grn_scorer_matched_record *record)
   } else {
     grn_obj casted_max_raw;
     GRN_FLOAT_INIT(&casted_max_raw, 0);
-    if (grn_obj_cast(ctx, &casted_max_raw, max_raw, GRN_FALSE) != GRN_SUCCESS) {
+    if (grn_obj_cast(ctx, max_raw, &casted_max_raw, GRN_FALSE) != GRN_SUCCESS) {
       GRN_OBJ_FIN(ctx, &casted_max_raw);
       return tf;
     } else {

  Added: test/command/suite/select/match_columns/scorer/tf_at_most/max/int32.expected (+58 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/match_columns/scorer/tf_at_most/max/int32.expected    2015-03-25 18:34:04 +0900 (16990dd)
@@ -0,0 +1,58 @@
+table_create Logs TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Logs message COLUMN_SCALAR Text
+[[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 index COLUMN_INDEX|WITH_POSITION Logs message
+[[0,0.0,0.0],true]
+load --table Logs
+[
+["message"],
+["Error"],
+["Error Error"],
+["Error Error Error"],
+["Error Error Error Error"]
+]
+[[0,0.0,0.0],4]
+select Logs   --match_columns 'scorer_tf_at_most(message, 3)'   --query 'error'   --output_columns '_score, message'   --sortby -_score
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        4
+      ],
+      [
+        [
+          "_score",
+          "Int32"
+        ],
+        [
+          "message",
+          "Text"
+        ]
+      ],
+      [
+        3,
+        "Error Error Error Error"
+      ],
+      [
+        3,
+        "Error Error Error"
+      ],
+      [
+        2,
+        "Error Error"
+      ],
+      [
+        1,
+        "Error"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/match_columns/scorer/tf_at_most/max/int32.test (+22 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/match_columns/scorer/tf_at_most/max/int32.test    2015-03-25 18:34:04 +0900 (03beb6d)
@@ -0,0 +1,22 @@
+table_create Logs TABLE_NO_KEY
+column_create Logs message COLUMN_SCALAR Text
+
+table_create Terms TABLE_PAT_KEY ShortText \
+  --default_tokenizer TokenBigram \
+  --normalizer NormalizerAuto
+column_create Terms index COLUMN_INDEX|WITH_POSITION Logs message
+
+load --table Logs
+[
+["message"],
+["Error"],
+["Error Error"],
+["Error Error Error"],
+["Error Error Error Error"]
+]
+
+select Logs \
+  --match_columns 'scorer_tf_at_most(message, 3)' \
+  --query 'error' \
+  --output_columns '_score, message' \
+  --sortby -_score
-------------- next part --------------
HTML����������������������������...
Download 



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