[Groonga-commit] droonga/fluent-plugin-droonga at 11acf8d [master] Add test about search distributor for queries with "groupBy"

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Dec 4 15:27:51 JST 2013


YUKI Hiroshi	2013-12-04 15:27:51 +0900 (Wed, 04 Dec 2013)

  New Revision: 11acf8de728b193c0cb989f8be95ee37c6ce1b84
  https://github.com/droonga/fluent-plugin-droonga/commit/11acf8de728b193c0cb989f8be95ee37c6ce1b84

  Message:
    Add test about search distributor for queries with "groupBy"

  Modified files:
    test/unit/plugin/distributor/test_search.rb

  Modified: test/unit/plugin/distributor/test_search.rb (+94 -0)
===================================================================
--- test/unit/plugin/distributor/test_search.rb    2013-12-04 15:03:34 +0900 (1f2df69)
+++ test/unit/plugin/distributor/test_search.rb    2013-12-04 15:27:51 +0900 (73489b9)
@@ -827,6 +827,100 @@ class SearchDistributorTest < Test::Unit::TestCase
       assert_equal(message, @posted.last.last)
     end
 
+    def test_groupBy
+      envelope = {
+        "type" => "search",
+        "dataset" => "Droonga",
+        "body" => {
+          "queries" => {
+            "grouped_records" => {
+              "source" => "User",
+              "groupBy" => "family_name",
+              "output" => {
+                "format" => "complex",
+                "elements" => ["records"],
+                "attributes" => ["_key", "_nsubrecs"],
+                "limit" => -1,
+              },
+            },
+          },
+        },
+      }
+
+      @plugin.process("search", envelope)
+
+      message = []
+      message << reducer(envelope, {
+        "records" => {
+          "type" => "sort",
+          "operators" => [],
+          "key_column" => 0,
+          "unified_columns" => [1],
+          "limit" => -1,
+        },
+      })
+      message << gatherer(envelope, :offset => 0,
+                                    :limit => -1,
+                                    :element => "records",
+                                    :format => "complex",
+                                    :attributes => ["_key", "_nsubrecs"])
+      message << searcher(envelope, :output_offset => 0,
+                                    :output_limit => -1)
+      assert_equal(message, @posted.last.last)
+    end
+
+    def test_groupBy_hash
+      envelope = {
+        "type" => "search",
+        "dataset" => "Droonga",
+        "body" => {
+          "queries" => {
+            "grouped_records" => {
+              "source" => "User",
+              "groupBy" => {
+                "key" => "family_name",
+                "maxNSubRecords" => 3,
+              },
+              "output" => {
+                "format" => "complex",
+                "elements" => ["records"],
+                "attributes" => [
+                  { "label" => "family_name", "source" => "_key" },
+                  { "label" => "count", "source" => "_nsubrecs" },
+                  { "label" => "users",
+                    "source" => "_subrecs",
+                    "attributes" => ["name", "age"] },
+                ],
+                "limit" => -1,
+              },
+            },
+          },
+        },
+      }
+
+      @plugin.process("search", envelope)
+
+      message = []
+      message << reducer(envelope, {
+        "records" => {
+          "type" => "sort",
+          "operators" => [],
+          "key_column" => 3, # 0=family_name, 1=_nsubrecs, 2=_subrecs, 3=_keys
+          "unified_columns" => [1, 2],
+          "limit" => -1,
+        },
+      })
+      message << gatherer(envelope, :offset => 0,
+                                    :limit => -1,
+                                    :element => "records",
+                                    :format => "complex",
+                                    :attributes => ["family_name", "count", "users"])
+      message << searcher(envelope, :output_offset => 0,
+                                    :output_limit => -1,
+                                    :extra_attributes => ["_key"])
+      assert_equal(message, @posted.last.last)
+    end
+
     private
     def reducer(search_request_envelope, reducer_body)
       queries = search_request_envelope["body"]["queries"]
-------------- next part --------------
HTML����������������������������...
Download 



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