[Groonga-commit] groonga/groonga at 89c5576 [master] Support multiple indexes including a nested index and multiple keywords query

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jan 13 20:25:35 JST 2014


Kouhei Sutou	2014-01-13 20:25:35 +0900 (Mon, 13 Jan 2014)

  New Revision: 89c5576a310aa86783804f959285874ac388d117
  https://github.com/groonga/groonga/commit/89c5576a310aa86783804f959285874ac388d117

  Message:
    Support multiple indexes including a nested index and multiple keywords query
    
    For example:
    
        select TABLE \
           --match_columns "column || nested.column" \
           --query "KERYWORD1 KEYROWRD2"
    
    See the following added tests for details.
    
      * test/command/suite/select/index/nested/match_columns/last/and.test
      * test/command/suite/select/index/nested/match_columns/middle/and.test

  Added files:
    test/command/suite/select/index/nested/match_columns/last/and.expected
    test/command/suite/select/index/nested/match_columns/last/and.test
    test/command/suite/select/index/nested/match_columns/last/and_not.expected
    test/command/suite/select/index/nested/match_columns/last/and_not.test
    test/command/suite/select/index/nested/match_columns/last/or.expected
    test/command/suite/select/index/nested/match_columns/last/or.test
    test/command/suite/select/index/nested/match_columns/middle/and.expected
    test/command/suite/select/index/nested/match_columns/middle/and.test
    test/command/suite/select/index/nested/match_columns/middle/and_not.expected
    test/command/suite/select/index/nested/match_columns/middle/and_not.test
    test/command/suite/select/index/nested/match_columns/middle/or.expected
    test/command/suite/select/index/nested/match_columns/middle/or.test
  Copied files:
    test/command/suite/select/function/sub_filter/and/match.expected
      (from test/command/suite/select/function/sub_filter/and.expected)
    test/command/suite/select/function/sub_filter/and/match.test
      (from test/command/suite/select/function/sub_filter/and.test)
  Modified files:
    lib/db.c
    lib/db.h
    lib/proc.c
  Renamed files:
    test/command/suite/select/function/sub_filter/and/not_match.expected
      (from test/command/suite/select/function/sub_filter/and.expected)
    test/command/suite/select/function/sub_filter/and/not_match.test
      (from test/command/suite/select/function/sub_filter/and.test)

  Modified: lib/db.c (+20 -9)
===================================================================
--- lib/db.c    2014-01-07 22:41:18 +0900 (13c9ab4)
+++ lib/db.c    2014-01-13 20:25:35 +0900 (a7b416b)
@@ -2640,7 +2640,7 @@ grn_table_next(grn_ctx *ctx, grn_obj *table, grn_id id)
 
 grn_rc
 grn_accessor_resolve(grn_ctx *ctx, grn_obj *accessor, int deep,
-                     grn_obj *base_res, grn_obj *res, grn_operator op,
+                     grn_obj *base_res, grn_obj **res,
                      grn_search_optarg *optarg)
 {
   grn_rc rc = GRN_SUCCESS;
@@ -2729,12 +2729,13 @@ grn_accessor_resolve(grn_ctx *ctx, grn_obj *accessor, int deep,
     }
   }
 
-  if (rc == GRN_SUCCESS) {
-    rc = grn_table_setoperation(ctx, res, current_res, res, op);
-  }
-
-  if (current_res != base_res) {
-    grn_obj_unlink(ctx, current_res);
+  if (rc == GRN_SUCCESS && current_res != base_res) {
+    *res = current_res;
+  } else {
+    *res = NULL;
+    if (rc == GRN_SUCCESS) {
+      rc = GRN_INVALID_ARGUMENT;
+    }
   }
 
   GRN_OBJ_FIN(ctx, &accessor_stack);
@@ -2778,6 +2779,7 @@ grn_obj_search_accessor(grn_ctx *ctx, grn_obj *obj, grn_obj *query,
       rc = grn_obj_search(ctx, index, query, res, op, optarg);
     } else {
       grn_obj *base_res;
+      grn_obj *resolve_res = NULL;
       grn_obj *range = grn_ctx_at(ctx, DB_OBJ(index)->range);
       base_res = grn_table_create(ctx, NULL, 0, NULL,
                                   GRN_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC,
@@ -2793,8 +2795,17 @@ grn_obj_search_accessor(grn_ctx *ctx, grn_obj *obj, grn_obj *query,
         grn_obj_unlink(ctx, base_res);
         goto exit;
       }
-      rc = grn_accessor_resolve(ctx, obj, n_accessors - 1, base_res, res, op,
-                                optarg);
+      rc = grn_accessor_resolve(ctx, obj, n_accessors - 1, base_res,
+                                &resolve_res, optarg);
+      if (resolve_res) {
+        if (op == GRN_OP_AND) {
+          grn_table_setoperation(ctx, res, resolve_res, res, GRN_OP_OR);
+          grn_ii_resolve_sel_and(ctx, (grn_hash *)res, op);
+        } else {
+          grn_table_setoperation(ctx, res, resolve_res, res, op);
+        }
+        grn_obj_unlink(ctx, resolve_res);
+      }
       grn_obj_unlink(ctx, base_res);
     }
   }

  Modified: lib/db.h (+1 -1)
===================================================================
--- lib/db.h    2014-01-07 22:41:18 +0900 (dc2fba4)
+++ lib/db.h    2014-01-13 20:25:35 +0900 (ee0da9d)
@@ -439,7 +439,7 @@ GRN_API grn_rc grn_column_filter(grn_ctx *ctx, grn_obj *column,
                                  grn_operator set_op);
 
 grn_rc grn_accessor_resolve(grn_ctx *ctx, grn_obj *accessor, int deep,
-                            grn_obj *base_res, grn_obj *res, grn_operator op,
+                            grn_obj *base_res, grn_obj **res,
                             grn_search_optarg *optarg);
 
 #ifdef __cplusplus

  Modified: lib/proc.c (+7 -2)
===================================================================
--- lib/proc.c    2014-01-07 22:41:18 +0900 (97b8ffc)
+++ lib/proc.c    2014-01-13 20:25:35 +0900 (18c5fd0)
@@ -3972,13 +3972,14 @@ run_sub_filter(grn_ctx *ctx, grn_obj *table,
 
   {
     grn_obj *base_res = NULL;
+    grn_obj *resolve_res = NULL;
 
     base_res = grn_table_create(ctx, NULL, 0, NULL,
                                 GRN_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC,
                                 scope_domain, NULL);
     grn_table_select(ctx, scope_domain, sub_filter, base_res, GRN_OP_OR);
     if (scope->header.type == GRN_ACCESSOR) {
-      rc = grn_accessor_resolve(ctx, scope, -1, base_res, res, op, NULL);
+      rc = grn_accessor_resolve(ctx, scope, -1, base_res, &resolve_res, NULL);
     } else {
       grn_accessor accessor;
       accessor.header.type = GRN_ACCESSOR;
@@ -3986,7 +3987,11 @@ run_sub_filter(grn_ctx *ctx, grn_obj *table,
       accessor.action = GRN_ACCESSOR_GET_COLUMN_VALUE;
       accessor.next = NULL;
       rc = grn_accessor_resolve(ctx, (grn_obj *)&accessor, -1, base_res,
-                                res, op, NULL);
+                                &resolve_res, NULL);
+    }
+    if (resolve_res) {
+      rc = grn_table_setoperation(ctx, res, resolve_res, res, op);
+      grn_obj_unlink(ctx, resolve_res);
     }
     grn_obj_unlink(ctx, base_res);
   }

  Copied: test/command/suite/select/function/sub_filter/and/match.expected (+0 -0) 100%
===================================================================

  Copied: test/command/suite/select/function/sub_filter/and/match.test (+0 -0) 100%
===================================================================

  Renamed: test/command/suite/select/function/sub_filter/and/not_match.expected (+2 -13) 86%
===================================================================
--- test/command/suite/select/function/sub_filter/and.expected    2014-01-07 22:41:18 +0900 (b9a8ad5)
+++ test/command/suite/select/function/sub_filter/and/not_match.expected    2014-01-13 20:25:35 +0900 (30946ee)
@@ -33,7 +33,7 @@ load --table Packages
 {"_key": "mroonga", "files": ["ha_mroonga.cc", "ha_mroonga.hpp"]}
 ]
 [[0,0.0,0.0],3]
-select Packages   --filter '_key @ "rroonga" && sub_filter(files, "revision >= 10 && revision < 40")'   --output_columns '_key, files, files.revision'
+select Packages   --filter '_key @ "rroonga" && sub_filter(files, "revision <= 10")'   --output_columns '_key, files, files.revision'
 [
   [
     0,
@@ -43,7 +43,7 @@ select Packages   --filter '_key @ "rroonga" && sub_filter(files, "revision >= 1
   [
     [
       [
-        1
+        0
       ],
       [
         [
@@ -58,17 +58,6 @@ select Packages   --filter '_key @ "rroonga" && sub_filter(files, "revision >= 1
           "files.revision",
           "UInt32"
         ]
-      ],
-      [
-        "rroonga",
-        [
-          "lib/groonga.rb",
-          "README.textile"
-        ],
-        [
-          12,
-          24
-        ]
       ]
     ]
   ]

  Renamed: test/command/suite/select/function/sub_filter/and/not_match.test (+1 -1) 92%
===================================================================
--- test/command/suite/select/function/sub_filter/and.test    2014-01-07 22:41:18 +0900 (a0202e6)
+++ test/command/suite/select/function/sub_filter/and/not_match.test    2014-01-13 20:25:35 +0900 (5225199)
@@ -31,5 +31,5 @@ load --table Packages
 ]
 
 select Packages \
-  --filter '_key @ "rroonga" && sub_filter(files, "revision >= 10 && revision < 40")' \
+  --filter '_key @ "rroonga" && sub_filter(files, "revision <= 10")' \
   --output_columns '_key, files, files.revision'

  Added: test/command/suite/select/index/nested/match_columns/last/and.expected (+41 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/last/and.expected    2014-01-13 20:25:35 +0900 (0228dd1)
@@ -0,0 +1,41 @@
+table_create Users TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Users name COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Memos TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Memos owner COLUMN_SCALAR Users
+[[0,0.0,0.0],true]
+column_create Memos title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Users name
+[[0,0.0,0.0],true]
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos title
+[[0,0.0,0.0],true]
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos content
+[[0,0.0,0.0],true]
+column_create Users memos COLUMN_INDEX Memos owner
+[[0,0.0,0.0],true]
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+[[0,0.0,0.0],3]
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."}
+]
+[[0,0.0,0.0],3]
+select Memos   --match_columns "title || content || owner.name"   --query "Alice Rroonga"   --output_columns '_key'
+[[0,0.0,0.0],[[[1],[["_key","ShortText"]],["alice2"]]]]

  Added: test/command/suite/select/index/nested/match_columns/last/and.test (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/last/and.test    2014-01-13 20:25:35 +0900 (1cd0954)
@@ -0,0 +1,39 @@
+table_create Users TABLE_PAT_KEY ShortText
+column_create Users name COLUMN_SCALAR ShortText
+
+table_create Memos TABLE_PAT_KEY ShortText
+column_create Memos owner COLUMN_SCALAR Users
+column_create Memos title COLUMN_SCALAR ShortText
+column_create Memos content COLUMN_SCALAR Text
+
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Users name
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos title
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos content
+
+column_create Users memos COLUMN_INDEX Memos owner
+
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."}
+]
+
+select Memos \
+  --match_columns "title || content || owner.name" \
+  --query "Alice Rroonga" \
+  --output_columns '_key'

  Added: test/command/suite/select/index/nested/match_columns/last/and_not.expected (+41 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/last/and_not.expected    2014-01-13 20:25:35 +0900 (0228dd1)
@@ -0,0 +1,41 @@
+table_create Users TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Users name COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Memos TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Memos owner COLUMN_SCALAR Users
+[[0,0.0,0.0],true]
+column_create Memos title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Users name
+[[0,0.0,0.0],true]
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos title
+[[0,0.0,0.0],true]
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos content
+[[0,0.0,0.0],true]
+column_create Users memos COLUMN_INDEX Memos owner
+[[0,0.0,0.0],true]
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+[[0,0.0,0.0],3]
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."}
+]
+[[0,0.0,0.0],3]
+select Memos   --match_columns "title || content || owner.name"   --query "Alice Rroonga"   --output_columns '_key'
+[[0,0.0,0.0],[[[1],[["_key","ShortText"]],["alice2"]]]]

  Added: test/command/suite/select/index/nested/match_columns/last/and_not.test (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/last/and_not.test    2014-01-13 20:25:35 +0900 (1cd0954)
@@ -0,0 +1,39 @@
+table_create Users TABLE_PAT_KEY ShortText
+column_create Users name COLUMN_SCALAR ShortText
+
+table_create Memos TABLE_PAT_KEY ShortText
+column_create Memos owner COLUMN_SCALAR Users
+column_create Memos title COLUMN_SCALAR ShortText
+column_create Memos content COLUMN_SCALAR Text
+
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Users name
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos title
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos content
+
+column_create Users memos COLUMN_INDEX Memos owner
+
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."}
+]
+
+select Memos \
+  --match_columns "title || content || owner.name" \
+  --query "Alice Rroonga" \
+  --output_columns '_key'

  Added: test/command/suite/select/index/nested/match_columns/last/or.expected (+43 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/last/or.expected    2014-01-13 20:25:35 +0900 (bedbd51)
@@ -0,0 +1,43 @@
+table_create Users TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Users name COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Memos TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Memos owner COLUMN_SCALAR Users
+[[0,0.0,0.0],true]
+column_create Memos title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Users name
+[[0,0.0,0.0],true]
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos title
+[[0,0.0,0.0],true]
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos content
+[[0,0.0,0.0],true]
+column_create Users memos COLUMN_INDEX Memos owner
+[[0,0.0,0.0],true]
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+[[0,0.0,0.0],3]
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."},
+{"_key": "carlos1", "owner": "carlos",
+ "title": "Nroonga", "content": "Nroonga is the node.js bindings of Groonga.."}
+]
+[[0,0.0,0.0],4]
+select Memos   --match_columns "title || content || owner.name"   --query "Carlos OR Mroonga"   --output_columns '_key'
+[[0,0.0,0.0],[[[2],[["_key","ShortText"]],["carlos1"],["bob1"]]]]

  Added: test/command/suite/select/index/nested/match_columns/last/or.test (+41 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/last/or.test    2014-01-13 20:25:35 +0900 (ecc769b)
@@ -0,0 +1,41 @@
+table_create Users TABLE_PAT_KEY ShortText
+column_create Users name COLUMN_SCALAR ShortText
+
+table_create Memos TABLE_PAT_KEY ShortText
+column_create Memos owner COLUMN_SCALAR Users
+column_create Memos title COLUMN_SCALAR ShortText
+column_create Memos content COLUMN_SCALAR Text
+
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Users name
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos title
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos content
+
+column_create Users memos COLUMN_INDEX Memos owner
+
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."},
+{"_key": "carlos1", "owner": "carlos",
+ "title": "Nroonga", "content": "Nroonga is the node.js bindings of Groonga.."}
+]
+
+select Memos \
+  --match_columns "title || content || owner.name" \
+  --query "Carlos OR Mroonga" \
+  --output_columns '_key'

  Added: test/command/suite/select/index/nested/match_columns/middle/and.expected (+41 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/middle/and.expected    2014-01-13 20:25:35 +0900 (1173d77)
@@ -0,0 +1,41 @@
+table_create Users TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Users name COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Memos TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Memos owner COLUMN_SCALAR Users
+[[0,0.0,0.0],true]
+column_create Memos title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Users name
+[[0,0.0,0.0],true]
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos title
+[[0,0.0,0.0],true]
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos content
+[[0,0.0,0.0],true]
+column_create Users memos COLUMN_INDEX Memos owner
+[[0,0.0,0.0],true]
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+[[0,0.0,0.0],3]
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."}
+]
+[[0,0.0,0.0],3]
+select Memos   --match_columns "title || owner.name || content"   --query "Alice Rroonga"   --output_columns '_key'
+[[0,0.0,0.0],[[[1],[["_key","ShortText"]],["alice2"]]]]

  Added: test/command/suite/select/index/nested/match_columns/middle/and.test (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/middle/and.test    2014-01-13 20:25:35 +0900 (fd13d64)
@@ -0,0 +1,39 @@
+table_create Users TABLE_PAT_KEY ShortText
+column_create Users name COLUMN_SCALAR ShortText
+
+table_create Memos TABLE_PAT_KEY ShortText
+column_create Memos owner COLUMN_SCALAR Users
+column_create Memos title COLUMN_SCALAR ShortText
+column_create Memos content COLUMN_SCALAR Text
+
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Users name
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos title
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos content
+
+column_create Users memos COLUMN_INDEX Memos owner
+
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."}
+]
+
+select Memos \
+  --match_columns "title || owner.name || content" \
+  --query "Alice Rroonga" \
+  --output_columns '_key'

  Added: test/command/suite/select/index/nested/match_columns/middle/and_not.expected (+41 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/middle/and_not.expected    2014-01-13 20:25:35 +0900 (1173d77)
@@ -0,0 +1,41 @@
+table_create Users TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Users name COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Memos TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Memos owner COLUMN_SCALAR Users
+[[0,0.0,0.0],true]
+column_create Memos title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Users name
+[[0,0.0,0.0],true]
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos title
+[[0,0.0,0.0],true]
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos content
+[[0,0.0,0.0],true]
+column_create Users memos COLUMN_INDEX Memos owner
+[[0,0.0,0.0],true]
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+[[0,0.0,0.0],3]
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."}
+]
+[[0,0.0,0.0],3]
+select Memos   --match_columns "title || owner.name || content"   --query "Alice Rroonga"   --output_columns '_key'
+[[0,0.0,0.0],[[[1],[["_key","ShortText"]],["alice2"]]]]

  Added: test/command/suite/select/index/nested/match_columns/middle/and_not.test (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/middle/and_not.test    2014-01-13 20:25:35 +0900 (fd13d64)
@@ -0,0 +1,39 @@
+table_create Users TABLE_PAT_KEY ShortText
+column_create Users name COLUMN_SCALAR ShortText
+
+table_create Memos TABLE_PAT_KEY ShortText
+column_create Memos owner COLUMN_SCALAR Users
+column_create Memos title COLUMN_SCALAR ShortText
+column_create Memos content COLUMN_SCALAR Text
+
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Users name
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos title
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos content
+
+column_create Users memos COLUMN_INDEX Memos owner
+
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."}
+]
+
+select Memos \
+  --match_columns "title || owner.name || content" \
+  --query "Alice Rroonga" \
+  --output_columns '_key'

  Added: test/command/suite/select/index/nested/match_columns/middle/or.expected (+43 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/middle/or.expected    2014-01-13 20:25:35 +0900 (e7fc949)
@@ -0,0 +1,43 @@
+table_create Users TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Users name COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Memos TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Memos owner COLUMN_SCALAR Users
+[[0,0.0,0.0],true]
+column_create Memos title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+[[0,0.0,0.0],true]
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Users name
+[[0,0.0,0.0],true]
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos title
+[[0,0.0,0.0],true]
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION   Memos content
+[[0,0.0,0.0],true]
+column_create Users memos COLUMN_INDEX Memos owner
+[[0,0.0,0.0],true]
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+[[0,0.0,0.0],3]
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."},
+{"_key": "carlos1", "owner": "carlos",
+ "title": "Nroonga", "content": "Nroonga is the node.js bindings of Groonga.."}
+]
+[[0,0.0,0.0],4]
+select Memos   --match_columns "title || owner.name || content"   --query "Carlos OR Mroonga"   --output_columns '_key'
+[[0,0.0,0.0],[[[2],[["_key","ShortText"]],["carlos1"],["bob1"]]]]

  Added: test/command/suite/select/index/nested/match_columns/middle/or.test (+41 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/nested/match_columns/middle/or.test    2014-01-13 20:25:35 +0900 (b42b54c)
@@ -0,0 +1,41 @@
+table_create Users TABLE_PAT_KEY ShortText
+column_create Users name COLUMN_SCALAR ShortText
+
+table_create Memos TABLE_PAT_KEY ShortText
+column_create Memos owner COLUMN_SCALAR Users
+column_create Memos title COLUMN_SCALAR ShortText
+column_create Memos content COLUMN_SCALAR Text
+
+table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram
+column_create Terms users_name COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Users name
+column_create Terms memos_title COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos title
+column_create Terms memos_content COLUMN_INDEX|WITH_SECTION|WITH_POSITION \
+  Memos content
+
+column_create Users memos COLUMN_INDEX Memos owner
+
+load --table Users
+[
+{"_key": "alice",  "name": "Alice"},
+{"_key": "bob",    "name": "Bob"},
+{"_key": "carlos", "name": "Carlos"}
+]
+
+load --table Memos
+[
+{"_key": "alice1", "owner": "alice",
+ "title": "Groonga", "content": "Groonga is full text search engine."},
+{"_key": "alice2", "owner": "alice",
+ "title": "Rroonga", "content": "Rroonga is the Ruby bindings of Groonga."},
+{"_key": "bob1", "owner": "bob",
+ "title": "Mroonga", "content": "Mroonga is a MySAL storage engine based on Groonga."},
+{"_key": "carlos1", "owner": "carlos",
+ "title": "Nroonga", "content": "Nroonga is the node.js bindings of Groonga.."}
+]
+
+select Memos \
+  --match_columns "title || owner.name || content" \
+  --query "Carlos OR Mroonga" \
+  --output_columns '_key'
-------------- next part --------------
HTML����������������������������...
Download 



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