[Groonga-commit] groonga/fluent-plugin-droonga at 81c9c2c [master] Support snippet_html()!

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Fri Jun 21 19:22:36 JST 2013


Kouhei Sutou	2013-06-21 19:22:36 +0900 (Fri, 21 Jun 2013)

  New Revision: 81c9c2cff6e10c53d2302f3db764e16b9c17ce70
  https://github.com/groonga/fluent-plugin-droonga/commit/81c9c2cff6e10c53d2302f3db764e16b9c17ce70

  Message:
    Support snippet_html()!
    
    GitHub: fixes #7

  Modified files:
    lib/droonga/plugin/handler_search.rb
    test/plugin/test_handler_search.rb

  Modified: lib/droonga/plugin/handler_search.rb (+5 -0)
===================================================================
--- lib/droonga/plugin/handler_search.rb    2013-06-21 18:34:06 +0900 (763abca)
+++ lib/droonga/plugin/handler_search.rb    2013-06-21 19:22:36 +0900 (67aa439)
@@ -91,6 +91,7 @@ module Droonga
         @context = context
         @query = query
         @result = nil
+        @condition = nil
         @start_time = nil
       end
 
@@ -201,6 +202,7 @@ module Droonga
           expression.define_variable(:domain => source)
           parseCondition(source, expression, @query["condition"])
           @result = source.select(expression)
+          @condition = expression
         end
         if @query["groupBy"]
           if @query["groupBy"].is_a? String
@@ -311,6 +313,9 @@ module Droonga
             expression = Groonga::Expression.new(context: @context)
             variable = expression.define_variable(domain: @result)
             expression.parse(source, syntax: :script)
+            condition = expression.define_variable(name: "$condition",
+                                                   reference: true)
+            condition.value = @condition
             source = nil
           end
           {

  Modified: test/plugin/test_handler_search.rb (+41 -0)
===================================================================
--- test/plugin/test_handler_search.rb    2013-06-21 18:34:06 +0900 (2333d4e)
+++ test/plugin/test_handler_search.rb    2013-06-21 19:22:36 +0900 (d7139c3)
@@ -387,6 +387,47 @@ class SearchHandlerTest < Test::Unit::TestCase
         }
         assert_search(expected, request)
       end
+
+      def test_snippet_html
+        expected = {
+          "sections-result" => {
+            "records" => [
+              {
+                "title" => "Groonga overview",
+                "snippet" => [
+                  "<span class=\"keyword\">Groonga</span> overview",
+                ],
+              },
+            ],
+          },
+        }
+        request = {
+          "queries" => {
+            "sections-result" => {
+              "source" => "Sections",
+              "condition" => {
+                "query" => "Groonga",
+                "matchTo" => ["title"],
+              },
+              "output" => {
+                "elements" => [
+                  "records",
+                ],
+                "format" => "complex",
+                "limit" => 1,
+                "attributes" => [
+                  "title",
+                  {
+                    "label" => "snippet",
+                    "source" => "snippet_html(title)",
+                  },
+                ],
+              },
+            },
+          },
+        }
+        assert_search(expected, request)
+      end
     end
 
     class FormatTest < self
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る