[Groonga-commit] groonga/groonga [master] add a test for broken reference drilldown.

Back to archive index

null+****@clear***** null+****@clear*****
2010年 7月 1日 (木) 07:40:52 JST


Kouhei Sutou	2010-06-30 22:40:52 +0000 (Wed, 30 Jun 2010)

  New Revision: 8f889f21c8bc6ae3d8738d3842bd60f6ea5ed486

  Log:
    add a test for broken reference drilldown.

  Added files:
    test/unit/fixtures/story/taiyaki/areas.grn
    test/unit/fixtures/story/taiyaki/categories.grn
  Modified files:
    test/unit/fixtures/story/taiyaki/ddl.grn
    test/unit/fixtures/story/taiyaki/shops.grn
    test/unit/story/taiyaki/test-geo.c

  Added: test/unit/fixtures/story/taiyaki/areas.grn (+26 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/fixtures/story/taiyaki/areas.grn    2010-06-30 22:40:52 +0000 (4d56418)
@@ -0,0 +1,26 @@
+load --table Areas
+[
+{"_key":"area0001",name:"東京都千代田区"},
+{"_key":"area0002",name:"東京都中央区"},
+{"_key":"area0003",name:"東京都港区"},
+{"_key":"area0004",name:"東京都新宿区"},
+{"_key":"area0005",name:"東京都文京区"},
+{"_key":"area0006",name:"東京都台東区"},
+{"_key":"area0007",name:"東京都墨田区"},
+{"_key":"area0008",name:"東京都江東区"},
+{"_key":"area0009",name:"東京都品川区"},
+{"_key":"area0010",name:"東京都目黒区"},
+{"_key":"area0011",name:"東京都大田区"},
+{"_key":"area0012",name:"東京都世田谷区"},
+{"_key":"area0013",name:"東京都渋谷区"},
+{"_key":"area0014",name:"東京都中野区"},
+{"_key":"area0015",name:"東京都杉並区"},
+{"_key":"area0016",name:"東京都豊島区"},
+{"_key":"area0017",name:"東京都北区"},
+{"_key":"area0018",name:"東京都千代田区"},
+{"_key":"area0019",name:"東京都荒川区"},
+{"_key":"area0020",name:"東京都板橋区"},
+{"_key":"area0021",name:"東京都練馬区"},
+{"_key":"area0022",name:"東京都足立区"},
+{"_key":"area0023",name:"東京都江戸川区"},
+]

  Added: test/unit/fixtures/story/taiyaki/categories.grn (+6 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/fixtures/story/taiyaki/categories.grn    2010-06-30 22:40:52 +0000 (2afbb29)
@@ -0,0 +1,6 @@
+load --table Categories
+[
+{"_key":"category0001",name:"和食"},
+{"_key":"category0002",name:"中華"},
+{"_key":"category0003",name:"おやつ"}
+]

  Modified: test/unit/fixtures/story/taiyaki/ddl.grn (+8 -0)
===================================================================
--- test/unit/fixtures/story/taiyaki/ddl.grn    2010-06-30 11:21:27 +0000 (721d915)
+++ test/unit/fixtures/story/taiyaki/ddl.grn    2010-06-30 22:40:52 +0000 (dac8522)
@@ -3,12 +3,20 @@ table_create Bigram TABLE_PAT_KEY|KEY_NORMALIZE ShortText --default_tokenizer To
 table_create Tags TABLE_PAT_KEY ShortText
 column_create Tags name COLUMN_SCALAR ShortText
 
+table_create Categories TABLE_HASH_KEY ShortText
+column_create Categories name COLUMN_SCALAR ShortText
+
+table_create Areas TABLE_HASH_KEY ShortText
+column_create Areas name COLUMN_SCALAR ShortText
+
 table_create Shops TABLE_HASH_KEY ShortText
 column_create Shops name COLUMN_SCALAR ShortText
 column_create Shops tags COLUMN_VECTOR Tags
 column_create Shops location COLUMN_SCALAR WGS84GeoPoint
 column_create Shops latitude COLUMN_SCALAR Int32
 column_create Shops longitude COLUMN_SCALAR Int32
+column_create Shops categories COLUMN_VECTOR Categories
+column_create Shops area COLUMN_SCALAR Areas
 
 column_create Tags index COLUMN_INDEX Shops tags
 column_create Bigram name COLUMN_INDEX|WITH_POSITION|WITH_SECTION Shops name

  Modified: test/unit/fixtures/story/taiyaki/shops.grn (+11 -11)
===================================================================
--- test/unit/fixtures/story/taiyaki/shops.grn    2010-06-30 11:21:27 +0000 (68a5e66)
+++ test/unit/fixtures/story/taiyaki/shops.grn    2010-06-30 22:40:52 +0000 (d8c0aa8)
@@ -1,6 +1,6 @@
 load --table Shops
 [
-{"_key":"nezu-no-taiyaki",name:"根津のたいやき","latitude":130322053,"longitude":504985073,"location":"130322053x504985073",tags:["たいやき","天然"]},
+{"_key":"nezu-no-taiyaki",name:"根津のたいやき","latitude":130322053,"longitude":504985073,"location":"130322053x504985073",tags:["たいやき","天然"],area:"area0005"},
 {"_key":"taiyaki-kataoka",name:"たい焼 カタオカ","latitude":130285021,"longitude":504715091,"location":"130285021x504715091",tags:["たいやき"]},
 {"_key":"soba-taiyaki-ku",name:"そばたいやき空","latitude":130117012,"longitude":504390088,"location":"130117012x504390088",tags:["たいやき"]},
 {"_key":"kuruma",name:"車","latitude":130335016,"longitude":504662007,"location":"130335016x504662007",tags:["たいやき"]},
@@ -13,27 +13,27 @@ load --table Shops
 {"_key":"miyoshi",name:"みよし","latitude":129885039,"longitude":503653023,"location":"129885039x503653023",tags:["たいやき"]},
 {"_key":"juju-ya",name:"寿々屋 菓子","latitude":129809022,"longitude":504597055,"location":"129809022x504597055",tags:["たいやき"]},
 {"_key":"tatsumi-ya",name:"たい焼き \/ たつみや","latitude":130015001,"longitude":504266057,"location":"130015001x504266057",tags:["たいやき"]},
-{"_key":"tetsuji",name:"たい焼き鉄次 大丸東京店","latitude":130089012,"longitude":505045070,"location":"130089012x505045070",tags:["たいやき"]},
+{"_key":"tetsuji",name:"たい焼き鉄次 大丸東京店","latitude":130089012,"longitude":505045070,"location":"130089012x505045070",tags:["たいやき"],categories:["category0003","category0001"]},
 {"_key":"gazuma-ya",name:"吾妻屋","latitude":130208017,"longitude":504315098,"location":"130208017x504315098",tags:["たいやき"]},
-{"_key":"honma-mon",name:"ほんま門","latitude":130347036,"longitude":504325073,"location":"130347036x504325073",tags:["たこやき"]},
+{"_key":"honma-mon",name:"ほんま門","latitude":130347036,"longitude":504325073,"location":"130347036x504325073",tags:["たこやき"],area:"area0014"},
 {"_key":"naniwa-ya",name:"浪花家","latitude":130380061,"longitude":505202034,"location":"130380061x505202034",tags:["たいやき","天然"]},
 {"_key":"kuro-dai",name:"代官山たい焼き黒鯛","latitude":129903045,"longitude":504648034,"location":"129903045x504648034",tags:["たいやき"]},
 {"_key":"daruma",name:"たいやき神田達磨 八重洲店","latitude":130094061,"longitude":505025099,"location":"130094061x505025099",tags:["たいやき"]},
-{"_key":"yanagi-ya",name:"柳屋 たい焼き","latitude":130133052,"longitude":505120058,"location":"130133052x505120058",tags:["たいやき","天然"]},
+{"_key":"yanagi-ya",name:"柳屋 たい焼き","latitude":130133052,"longitude":505120058,"location":"130133052x505120058",tags:["たいやき","天然"],area:"area0002"},
 {"_key":"sharaku",name:"たい焼き写楽","latitude":130329069,"longitude":505188046,"location":"130329069x505188046",tags:["たいやき","天然"]},
 {"_key":"takane",name:"たかね 和菓子","latitude":130226001,"longitude":503769013,"location":"130226001x503769013",tags:["たいやき","天然","和菓子"]},
 {"_key":"chiyoda",name:"たい焼き ちよだ","latitude":129866001,"longitude":504328017,"location":"129866001x504328017",tags:["たいやき"]},
 {"_key":"da-ka-po",name:"ダ・カーポ","latitude":129786048,"longitude":504792049,"location":"129786048x504792049",tags:["たいやき","カレー"]},
-{"_key":"matsushima-ya",name:"松島屋","latitude":129845056,"longitude":504853081,"location":"129845056x504853081",tags:["和菓子"]},
-{"_key":"kazuya",name:"銀座 かずや","latitude":130055008,"longitude":504968095,"location":"130055008x504968095",tags:["和菓子"]},
-{"_key":"furuya-kogane-an",name:"ふるや古賀音庵 和菓子","latitude":130086003,"longitude":504480071,"location":"130086003x504480071",tags:["和菓子"]},
-{"_key":"hachi-no-ie",name:"蜂の家 自由が丘本店","latitude":129680021,"longitude":504441006,"location":"129680021x504441006",tags:["和菓子"]},
+{"_key":"matsushima-ya",name:"松島屋","latitude":129845056,"longitude":504853081,"location":"129845056x504853081",tags:["和菓子"],categories:["和食"]},
+{"_key":"kazuya",name:"銀座 かずや","latitude":130055008,"longitude":504968095,"location":"130055008x504968095",tags:["和菓子"],categories:["和食"]},
+{"_key":"furuya-kogane-an",name:"ふるや古賀音庵 和菓子","latitude":130086003,"longitude":504480071,"location":"130086003x504480071",tags:["和菓子"],categories:["和食"]},
+{"_key":"hachi-no-ie",name:"蜂の家 自由が丘本店","latitude":129680021,"longitude":504441006,"location":"129680021x504441006",tags:["和菓子"],categories:["和食"]},
 {"_key":"azuki-chan",name:"薄皮たい焼き あづきちゃん","latitude":129855010,"longitude":504452003,"location":"129855010x504452003",tags:["たいやき"]},
 {"_key":"kuriko-an",name:"横浜 くりこ庵 浅草店","latitude":130280013,"longitude":505208029,"location":"130280013x505208029",tags:["たいやき"]},
 {"_key":"yume-no-aru-machi-no-taiyaki-ya-san",name:"夢ある街のたいやき屋さん戸越銀座店","latitude":129721099,"longitude":504685024,"location":"129721099x504685024",tags:["たいやき"]},
 {"_key":"naze-ya",name:"何故屋","latitude":129690039,"longitude":504418033,"location":"129690039x504418033",tags:["たいやき"]},
-{"_key":"sanoki-ya",name:"築地 さのきや","latitude":130019020,"longitude":505027021,"location":"130019020x505027021",tags:["たいやき","マグロ"]},
-{"_key":"shigeta",name:"しげ田","latitude":130046026,"longitude":505082073,"location":"130046026x505082073",tags:["たいやき","和菓子"]},
+{"_key":"sanoki-ya",name:"築地 さのきや","latitude":130019020,"longitude":505027021,"location":"130019020x505027021",tags:["たいやき","マグロ"],categories:"",area:"area0002"},
+{"_key":"shigeta",name:"しげ田","latitude":130046026,"longitude":505082073,"location":"130046026x505082073",tags:["たいやき","和菓子"],area:"area0002"},
 {"_key":"nishimi-ya",name:"にしみや 甘味処","latitude":130038025,"longitude":505066028,"location":"130038025x505066028",tags:["たいやき","おでん"]},
-{"_key":"hiiragi",name:"たいやきひいらぎ","latitude":129917001,"longitude":504675017,"location":"129917001x504675017",tags:["たいやき"]}
+{"_key":"hiiragi",name:"たいやきひいらぎ","latitude":129917001,"longitude":504675017,"location":"129917001x504675017",tags:["たいやき"],area:"area0013"}
 ]

  Modified: test/unit/story/taiyaki/test-geo.c (+90 -13)
===================================================================
--- test/unit/story/taiyaki/test-geo.c    2010-06-30 11:21:27 +0000 (68ba609)
+++ test/unit/story/taiyaki/test-geo.c    2010-06-30 22:40:52 +0000 (979d3ab)
@@ -25,6 +25,7 @@ void test_in_circle(void);
 void test_filter_by_tag_and_sort_by_distance_from_tokyo_tocho(void);
 void test_but_white(void);
 void test_drilldown(void);
+void test_drilldown_with_broken_reference(void);
 void test_weight_match(void);
 
 static gchar *tmp_directory;
@@ -74,6 +75,8 @@ cut_setup(void)
   database = grn_db_create(context, database_path, NULL);
 
   assert_send_commands(cut_get_fixture_data_string("ddl.grn", NULL));
+  assert_send_command(cut_get_fixture_data_string("areas.grn", NULL));
+  assert_send_command(cut_get_fixture_data_string("categories.grn", NULL));
   assert_send_command(cut_get_fixture_data_string("shops.grn", NULL));
 }
 
@@ -223,16 +226,31 @@ test_drilldown(void)
     "[\"根津のたいやき\",7812],"
     "[\"尾長屋 錦糸町店\",8314],"
     "[\"横浜 くりこ庵 浅草店\",8394],"
-    "[\"たいやきひいらぎ\",9242]],"
+    "[\"たいやきひいらぎ\",9242]],\n"
     "[[6],"
-    "[[\"_key\",\"ShortText\"],[\"_nsubrecs\",\"Int32\"]],"
-    "[\"たいやき\",13],"
-    "[\"天然\",3],"
-    "[\"白\",1],"
-    "[\"マグロ\",1],"
-    "[\"和菓子\",1],"
-    "[\"おでん\",1]"
-    "]]",
+     "[[\"_key\",\"ShortText\"],"
+      "[\"name\",\"ShortText\"],"
+      "[\"_nsubrecs\",\"Int32\"]],"
+     "[\"おでん\",\"\",1],"
+     "[\"たいやき\",\"\",13],"
+     "[\"マグロ\",\"\",1],"
+     "[\"和菓子\",\"\",1],"
+     "[\"天然\",\"\",3],"
+     "[\"白\",\"\",1]],\n"
+    "[[2],"
+     "[[\"_key\",\"ShortText\"],"
+      "[\"name\",\"ShortText\"],"
+      "[\"_nsubrecs\",\"Int32\"]],"
+     "[\"category0001\",\"和食\",1],"
+     "[\"category0003\",\"おやつ\",1]],\n"
+    "[[3],"
+     "[[\"_key\",\"ShortText\"],"
+      "[\"name\",\"ShortText\"],"
+      "[\"_nsubrecs\",\"Int32\"]],"
+     "[\"area0002\",\"東京都中央区\",3],"
+     "[\"area0005\",\"東京都文京区\",1],"
+     "[\"area0013\",\"東京都渋谷区\",1]]"
+     "]",
     send_command(
       cut_take_printf(
         "select Shops "
@@ -240,9 +258,68 @@ test_drilldown(void)
         "--output_columns 'name, _score' "
         "--filter 'geo_in_circle(location, \"%s\", %d) && tags @ \"たいやき\"' "
         "--scorer '_score=geo_distance(location, \"%s\")' "
-        "--drilldown_output_columns '_key, _nsubrecs' "
-        "--drilldown_sortby '-_nsubrecs' "
-        "--drilldown 'tags' ",
+        "--drilldown 'tags categories area' "
+        "--drilldown_output_columns '_key, name, _nsubrecs' "
+        "--drilldown_sortby '_key'",
+        grn_test_location_string(yurakucho_latitude, yurakucho_longitude),
+        distance,
+        grn_test_location_string(yurakucho_latitude, yurakucho_longitude))));
+}
+
+void
+test_drilldown_with_broken_reference(void)
+{
+  gdouble yurakucho_latitude = 35.67487;
+  gdouble yurakucho_longitude = 139.76352;
+  gint distance = 10 * 1000;
+
+  assert_send_commands("delete Areas area0002");
+  assert_send_commands("delete Areas area0005");
+  cut_assert_equal_string(
+    "[[[13],"
+    "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"]],"
+    "[\"たいやき神田達磨 八重洲店\",1079],"
+    "[\"たい焼き鉄次 大丸東京店\",1390],"
+    "[\"築地 さのきや\",1723],"
+    "[\"にしみや 甘味処\",2000],"
+    "[\"しげ田\",2272],"
+    "[\"柳屋 たい焼き\",3686],"
+    "[\"根津のたいやき\",7812],"
+    "[\"尾長屋 錦糸町店\",8314],"
+    "[\"横浜 くりこ庵 浅草店\",8394],"
+    "[\"たいやきひいらぎ\",9242]],\n"
+    "[[6],"
+     "[[\"_key\",\"ShortText\"],"
+      "[\"name\",\"ShortText\"],"
+      "[\"_nsubrecs\",\"Int32\"]],"
+     "[\"おでん\",\"\",1],"
+     "[\"たいやき\",\"\",13],"
+     "[\"マグロ\",\"\",1],"
+     "[\"和菓子\",\"\",1],"
+     "[\"天然\",\"\",3],"
+     "[\"白\",\"\",1]],\n"
+    "[[2],"
+     "[[\"_key\",\"ShortText\"],"
+      "[\"name\",\"ShortText\"],"
+      "[\"_nsubrecs\",\"Int32\"]],"
+     "[\"category0001\",\"和食\",1],"
+     "[\"category0003\",\"おやつ\",1]],\n"
+    "[[1],"
+     "[[\"_key\",\"ShortText\"],"
+      "[\"name\",\"ShortText\"],"
+      "[\"_nsubrecs\",\"Int32\"]],"
+     "[\"area00013\",\"東京都渋谷区\",1]]"
+     "]",
+    send_command(
+      cut_take_printf(
+        "select Shops "
+        "--sortby '+_score, +name' "
+        "--output_columns 'name, _score' "
+        "--filter 'geo_in_circle(location, \"%s\", %d) && tags @ \"たいやき\"' "
+        "--scorer '_score=geo_distance(location, \"%s\")' "
+        "--drilldown 'tags categories area' "
+        "--drilldown_output_columns '_key, name, _nsubrecs' "
+        "--drilldown_sortby '_key'",
         grn_test_location_string(yurakucho_latitude, yurakucho_longitude),
         distance,
         grn_test_location_string(yurakucho_latitude, yurakucho_longitude))));
@@ -267,7 +344,7 @@ test_weight_match(void)
     "[\"たいやきひいらぎ\",1759],"
     "[\"尾長屋 錦糸町店\",1687],"
     "[\"横浜 くりこ庵 浅草店\",1607],"
-    "[\"たい焼き写楽\",651]],"
+    "[\"たい焼き写楽\",651]],\n"
     "[[6],"
     "[[\"_key\",\"ShortText\"],[\"_nsubrecs\",\"Int32\"]],"
     "[\"たいやき\",13],"




Groonga-commit メーリングリストの案内
Back to archive index