24 #include "../lib/grn-assertions.h"
35 static gchar *tmp_directory;
44 "command-select-sort",
51 g_free(tmp_directory);
55 remove_tmp_directory(
void)
57 cut_remove_path(tmp_directory, NULL);
64 "column_create Sites score COLUMN_SCALAR Int32\n"
65 "column_create Sites age COLUMN_SCALAR Int32\n"
66 "column_create Sites description COLUMN_SCALAR ShortText");
69 "column_create Users name COLUMN_SCALAR ShortText");
72 "column_create Bookmarks site COLUMN_SCALAR Sites\n"
73 "column_create Bookmarks user COLUMN_SCALAR Users\n"
74 "column_create Bookmarks rank COLUMN_SCALAR Int32");
77 "--source Bookmarks.user");
80 "--default_tokenizer TokenBigram\n"
81 "column_create Bigram description "
82 "COLUMN_INDEX|WITH_POSITION Sites description");
91 "[\"_key\", \"score\", \"age\", \"description\"],\n"
92 "[\"groonga.org\", 100, 2, "
93 "\"fulltext search engine and column store\"],\n"
94 "[\"qwik.jp/senna/FrontPageJ.html\", 100, 5, "
95 "\"embeddable fulltext search engine\"],\n"
96 "[\"2ch.net\", 10, 11, \"BBS\"]\n"
101 "[\"_key\", \"name\"],\n"
102 "[\"morita\", \"Daijiro MORI\"],\n"
103 "[\"gunyara-kun\", \"Tasuku SUENAGA\"],\n"
104 "[\"yu\", \"Yutaro Shimamura\"]\n"
109 "[\"site\", \"user\", \"rank\"],\n"
110 "[\"groonga.org\", \"morita\", 100],\n"
111 "[\"groonga.org\", \"gunyara-kun\", 100],\n"
112 "[\"groonga.org\", \"yu\", 50],\n"
113 "[\"2ch.net\", \"gunyara-kun\", null],\n"
114 "[\"2ch.net\", \"yu\", 10]\n"
121 const gchar *database_path;
123 remove_tmp_directory();
124 g_mkdir_with_parents(tmp_directory, 0700);
129 database_path = cut_build_path(tmp_directory,
"database.groonga", NULL);
145 remove_tmp_directory();
151 cut_assert_equal_string(
153 "[[\"_key\",\"ShortText\"],"
154 "[\"score\",\"Int32\"],"
155 "[\"age\",\"Int32\"]],"
156 "[\"qwik.jp/senna/FrontPageJ.html\",100,5],"
157 "[\"groonga.org\",100,2],"
158 "[\"2ch.net\",10,11]]]",
160 "--sortby \"-score, -age\" "
161 "--output_columns \"_key, score, age\""));
167 cut_assert_equal_string(
169 "[[\"site._key\",\"ShortText\"],"
170 "[\"user._key\",\"ShortText\"],"
171 "[\"rank\",\"Int32\"]],"
172 "[\"groonga.org\",\"morita\",100],"
173 "[\"groonga.org\",\"gunyara-kun\",100],"
174 "[\"groonga.org\",\"yu\",50],"
175 "[\"2ch.net\",\"gunyara-kun\",0],"
176 "[\"2ch.net\",\"yu\",10]],"
178 "[[\"_key\",\"ShortText\"],"
179 "[\"_nsubrecs\",\"Int32\"]],"
181 "[\"groonga.org\",3]],"
183 "[[\"_key\",\"ShortText\"],"
184 "[\"_nsubrecs\",\"Int32\"]],"
185 "[\"gunyara-kun\",2],"
189 "[[\"_key\",\"Int32\"],"
190 "[\"_nsubrecs\",\"Int32\"]],"
196 "--output_columns \"site._key, user._key, rank\" "
197 "--sortby \"-site.score, -site.age\" "
198 "--drilldown \"site, user, rank\" "
199 "--drilldown_output_columns \"_key, _nsubrecs\" "
200 "--drilldown_sortby \"_key\""));
206 cut_assert_equal_string(
208 "[[\"_key\",\"ShortText\"]],"
211 "[\"qwik.jp/senna/FrontPageJ.html\"]]]",
213 "--sortby \"_score\" "
214 "--output_columns \"_key\""));
220 cut_assert_equal_string(
222 "[[\"_id\",\"UInt32\"],"
223 "[\"site._key\",\"ShortText\"],"
224 "[\"user._key\",\"ShortText\"]],"
225 "[5,\"2ch.net\",\"yu\"],"
226 "[4,\"2ch.net\",\"gunyara-kun\"],"
227 "[3,\"groonga.org\",\"yu\"],"
228 "[2,\"groonga.org\",\"gunyara-kun\"],"
229 "[1,\"groonga.org\",\"morita\"]],"
231 "[[\"_key\",\"ShortText\"],"
232 "[\"_nsubrecs\",\"Int32\"]],"
234 "[\"groonga.org\",3]],"
236 "[[\"_key\",\"ShortText\"],"
237 "[\"_nsubrecs\",\"Int32\"]],"
238 "[\"gunyara-kun\",2],"
242 "[[\"_key\",\"Int32\"],"
243 "[\"_nsubrecs\",\"Int32\"]],"
249 "--sortby \"_score,-_id\" "
250 "--output_columns \"_id, site._key, user._key\" "
251 "--drilldown \"site user rank\" "
252 "--drilldown_output_columns \"_key, _nsubrecs\" "
253 "--drilldown_sortby \"_key\""));
262 "invalid sort key: <nonexistent>(<_score,nonexistent>)",
264 "--sortby \"_score,nonexistent\" "
265 "--output_columns \"_key\"");
271 cut_assert_equal_string(
273 "[[\"_key\",\"ShortText\"],[\"description\",\"ShortText\"]],"
274 "[\"qwik.jp/senna/FrontPageJ.html\","
275 "\"embeddable fulltext search engine\"],"
277 "\"fulltext search engine and column store\"]]]",
279 "--sortby \"description\" "
280 "--output_columns \"_key, description\" "
281 "--match_columns \"description\" "
282 "--query \"fulltext\""));
289 "column_create Ages site_index COLUMN_INDEX Sites age");
292 "[\"_key\", \"score\", \"age\", \"description\"],\n"
293 "[\"mroonga.github.com\", 100, 2, "
294 "\"fast fulltext search on MySQL\"],\n"
295 "[\"groonga.rubyforge.org\", 100, 1, "
296 "\"Ruby bindings for groonga\"]\n"
299 cut_assert_equal_string(
301 "[[\"age\",\"Int32\"],[\"_key\",\"ShortText\"]],"
302 "[1,\"groonga.rubyforge.org\"],"
303 "[2,\"groonga.org\"],"
304 "[2,\"mroonga.github.com\"],"
305 "[5,\"qwik.jp/senna/FrontPageJ.html\"],"
306 "[11,\"2ch.net\"]]]",
309 "--output_columns \"age, _key\" "
310 "--match_columns \"description\" "
311 "--query \"fulltext OR BBS OR groonga\""));
318 "column_create Ages site_index COLUMN_INDEX Sites age");
321 "[\"_key\", \"score\", \"age\", \"description\"],\n"
322 "[\"mroonga.github.com\", 100, 2, "
323 "\"fast fulltext search on MySQL\"],\n"
324 "[\"groonga.rubyforge.org\", 100, 1, "
325 "\"Ruby bindings for groonga\"]\n"
328 cut_assert_equal_string(
330 "[[\"age\",\"Int32\"],[\"_key\",\"ShortText\"]],"
331 "[1,\"groonga.rubyforge.org\"],"
332 "[2,\"groonga.org\"],"
333 "[2,\"mroonga.github.com\"],"
334 "[5,\"qwik.jp/senna/FrontPageJ.html\"],"
335 "[11,\"2ch.net\"]]]",
338 "--output_columns \"age, _key\""));