[Groonga-commit] groonga/groonga [master] Support snippet_html("STRING" + "STRING")

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Dec 4 00:14:50 JST 2012


Kouhei Sutou	2012-12-04 00:14:50 +0900 (Tue, 04 Dec 2012)

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

  Log:
    Support snippet_html("STRING" + "STRING")
    
    Reported by Tomoatsu Shimada. Thanks!!!

  Added files:
    test/command/suite/select/function/snippet_html/concat.expected
    test/command/suite/select/function/snippet_html/concat.test
  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+7 -3)
===================================================================
--- lib/expr.c    2012-12-03 23:29:45 +0900 (9ab0a25)
+++ lib/expr.c    2012-12-04 00:14:50 +0900 (8915385)
@@ -3218,9 +3218,13 @@ grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs)
           ARITHMETIC_OPERATION_NO_CHECK,
           ARITHMETIC_OPERATION_NO_CHECK,
           {
-            GRN_BULK_REWIND(res);
-            grn_obj_cast(ctx, x, res, GRN_FALSE);
-            grn_obj_cast(ctx, y, res, GRN_FALSE);
+            if (x == res) {
+              grn_obj_cast(ctx, y, res, GRN_FALSE);
+            } else {
+              GRN_BULK_REWIND(res);
+              grn_obj_cast(ctx, x, res, GRN_FALSE);
+              grn_obj_cast(ctx, y, res, GRN_FALSE);
+            }
           }
           ,);
         break;

  Added: test/command/suite/select/function/snippet_html/concat.expected (+51 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_html/concat.expected    2012-12-04 00:14:50 +0900 (6278d2f)
@@ -0,0 +1,51 @@
+table_create Documents TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Documents title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Documents content COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+table_create Terms TABLE_PAT_KEY|KEY_NORMALIZE ShortText   --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Terms document_title_index COLUMN_INDEX|WITH_POSITION   Documents title
+[[0,0.0,0.0],true]
+column_create Terms document_content_index COLUMN_INDEX|WITH_POSITION   Documents content
+[[0,0.0,0.0],true]
+load --table Documents
+[
+["title", "content"],
+["Groonga overview", "Groonga is a fast and accurate full text search engine based on inverted index."],
+["Full text search and Instant update", "In widely used DBMSs, updates are immediately processed, for example, a newly registered record appears in the result of the next query."],
+["Column store and aggregate query", "People can collect more than enough data in the Internet era."]
+]
+[[0,0.0,0.0],3]
+select Documents   --match_columns title||content --query 'groonga'   --output_columns '_id, snippet_html(title + " " + content)'   --command_version 2
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "snippet_html",
+          "null"
+        ]
+      ],
+      [
+        1,
+        [
+          "<span class=\"keyword\">Groonga</span> overview <span class=\"keyword\">Groonga</span> is a fast and accurate full text search engine based on inverted index."
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/function/snippet_html/concat.test (+23 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/snippet_html/concat.test    2012-12-04 00:14:50 +0900 (f2d13cb)
@@ -0,0 +1,23 @@
+table_create Documents TABLE_NO_KEY
+column_create Documents title COLUMN_SCALAR ShortText
+column_create Documents content COLUMN_SCALAR Text
+
+table_create Terms TABLE_PAT_KEY|KEY_NORMALIZE ShortText \
+  --default_tokenizer TokenBigram
+column_create Terms document_title_index COLUMN_INDEX|WITH_POSITION \
+  Documents title
+column_create Terms document_content_index COLUMN_INDEX|WITH_POSITION \
+  Documents content
+
+load --table Documents
+[
+["title", "content"],
+["Groonga overview", "Groonga is a fast and accurate full text search engine based on inverted index."],
+["Full text search and Instant update", "In widely used DBMSs, updates are immediately processed, for example, a newly registered record appears in the result of the next query."],
+["Column store and aggregate query", "People can collect more than enough data in the Internet era."]
+]
+
+select Documents \
+  --match_columns title||content --query 'groonga' \
+  --output_columns '_id, snippet_html(title + " " + content)' \
+  --command_version 2
-------------- next part --------------
HTML����������������������������...
Download 



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