groonga-command 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/text/news.md +23 -0
- data/lib/groonga/command/base.rb +11 -2
- data/lib/groonga/command/select.rb +78 -3
- data/lib/groonga/command/version.rb +1 -1
- data/test/command/test-select.rb +93 -3
- metadata +42 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5d52462003c9ca479ef592591f48e0b9d001fe1
|
4
|
+
data.tar.gz: bad56b2b66c55244d5385ca60f73b2ca94d81c57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6fc11658893bb743cef7a9bd77ff4b1e38061c2d08ebd4932e0f555a095b71b6963379ab70d7981ce5cc19467edef208ad86a7bb64d7063246c2776f7c3bcd9
|
7
|
+
data.tar.gz: fe21795f21cb493d9a7f6f38fc09759a93cf2f20678804d821e99fdccb65461d7d29fe418dd753068604a7bdb590dfaa628774f6e92dcd1439228b3ebbb15937
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 1.2.8: 2016-10-11
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* {Groonga::Command::Select}: Supported labeled drilldowns.
|
8
|
+
|
9
|
+
* {Groonga::Command::Select}: Supported `adjuster` parameter.
|
10
|
+
|
11
|
+
* {Groonga::Command::Select}: Supported `drilldown_calc_types` parameter.
|
12
|
+
|
13
|
+
* {Groonga::Command::Select}: Supported `drilldown_calc_target` parameter.
|
14
|
+
|
15
|
+
* {Groonga::Command::Select}: Supported `sort_keys` parameter.
|
16
|
+
|
17
|
+
* {Groonga::Command::Select}: Supported `drilldown_sort_keys` parameter.
|
18
|
+
|
19
|
+
* {Groonga::Command::Select#sort_keys}: Added.
|
20
|
+
|
21
|
+
* {Groonga::Command::Select#sortby}: Deprecated. Use
|
22
|
+
{Groonga::Command::Select#sort_keys} instead.
|
23
|
+
|
24
|
+
* {Groonga::Command::Select#drilldown_sort_keys}: Added.
|
25
|
+
|
3
26
|
## 1.2.7: 2016-08-15
|
4
27
|
|
5
28
|
### Improvements
|
data/lib/groonga/command/base.rb
CHANGED
@@ -184,8 +184,12 @@ module Groonga
|
|
184
184
|
end
|
185
185
|
|
186
186
|
def integer_value(name)
|
187
|
-
|
187
|
+
parse_integer_value(self[name])
|
188
|
+
end
|
189
|
+
|
190
|
+
def parse_integer_value(value)
|
188
191
|
return value if value.nil?
|
192
|
+
return nil if value.empty?
|
189
193
|
|
190
194
|
begin
|
191
195
|
Integer(value)
|
@@ -195,7 +199,12 @@ module Groonga
|
|
195
199
|
end
|
196
200
|
|
197
201
|
def array_value(name)
|
198
|
-
(self[name] || "")
|
202
|
+
parse_array_value(self[name] || "")
|
203
|
+
end
|
204
|
+
|
205
|
+
def parse_array_value(value)
|
206
|
+
return nil if value.nil?
|
207
|
+
value.strip.split(/\s*,\s*/)
|
199
208
|
end
|
200
209
|
end
|
201
210
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2012-2016 Kouhei Sutou <kou@clear-code.com>
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -47,16 +45,32 @@ module Groonga
|
|
47
45
|
:query_expansion,
|
48
46
|
:query_flags,
|
49
47
|
:query_expander,
|
48
|
+
:adjuster,
|
49
|
+
:drilldown_calc_types,
|
50
|
+
:drilldown_calc_target,
|
51
|
+
:sort_keys,
|
52
|
+
:drilldown_sort_keys,
|
50
53
|
]
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
54
57
|
Command.register(command_name, self)
|
55
58
|
|
59
|
+
# @return [String] The sort keys as String. Each key is
|
60
|
+
# separated by "," or spaces.
|
61
|
+
#
|
62
|
+
# @deprecated since 1.2.8. Use {#sort_keys} instead.
|
56
63
|
def sortby
|
57
64
|
self[:sortby]
|
58
65
|
end
|
59
66
|
|
67
|
+
# @return [::Array<String>] The sort keys.
|
68
|
+
#
|
69
|
+
# @since 1.2.8
|
70
|
+
def sort_keys
|
71
|
+
parse_array_value(self[:sort_keys] || self[:sortby] || "")
|
72
|
+
end
|
73
|
+
|
60
74
|
def scorer
|
61
75
|
self[:scorer]
|
62
76
|
end
|
@@ -77,6 +91,21 @@ module Groonga
|
|
77
91
|
@drilldowns ||= array_value(:drilldown)
|
78
92
|
end
|
79
93
|
|
94
|
+
# @return [::Array<String>] The sort keys for drilldowns.
|
95
|
+
#
|
96
|
+
# @since 1.2.8
|
97
|
+
def drilldown_sort_keys
|
98
|
+
value = self[:drilldown_sort_keys] || self[:drilldown_sortby] || ""
|
99
|
+
parse_array_value(value)
|
100
|
+
end
|
101
|
+
|
102
|
+
# @return [::Hash<String, Drilldown>] The labeled drilldowns.
|
103
|
+
#
|
104
|
+
# @since 1.2.8
|
105
|
+
def labeled_drilldowns
|
106
|
+
@labeled_drilldowns ||= parse_labeled_drilldowns
|
107
|
+
end
|
108
|
+
|
80
109
|
def output_columns
|
81
110
|
self[:output_columns]
|
82
111
|
end
|
@@ -90,6 +119,52 @@ module Groonga
|
|
90
119
|
condition
|
91
120
|
end
|
92
121
|
end
|
122
|
+
|
123
|
+
def parse_labeled_drilldowns
|
124
|
+
raw_labeled_drilldowns = {}
|
125
|
+
@arguments.each do |name, value|
|
126
|
+
case name.to_s
|
127
|
+
when /\Adrilldowns?\[(.+?)\]\.(.+?)\z/
|
128
|
+
label = $1
|
129
|
+
parameter_name = $2
|
130
|
+
raw_labeled_drilldowns[label] ||= {}
|
131
|
+
raw_labeled_drilldowns[label][parameter_name] = value
|
132
|
+
end
|
133
|
+
end
|
134
|
+
build_labeled_drilldowns(raw_labeled_drilldowns)
|
135
|
+
end
|
136
|
+
|
137
|
+
def build_labeled_drilldowns(raw_labeled_drilldowns)
|
138
|
+
labeled_drilldowns = {}
|
139
|
+
raw_labeled_drilldowns.each do |label, raw_drilldown|
|
140
|
+
keys = parse_array_value(raw_drilldown["keys"])
|
141
|
+
sort_keys = raw_drilldown["sort_keys"] || raw_drilldown["sortby"]
|
142
|
+
sort_keys = parse_array_value(sort_keys)
|
143
|
+
output_columns = parse_array_value(raw_drilldown["output_columns"])
|
144
|
+
offset = parse_integer_value(raw_drilldown["offset"])
|
145
|
+
limit = parse_integer_value(raw_drilldown["limit"])
|
146
|
+
calc_types = parse_array_value(raw_drilldown["calc_types"])
|
147
|
+
calc_target = raw_drilldown["calc_target"]
|
148
|
+
drilldown = Drilldown.new(keys,
|
149
|
+
sort_keys,
|
150
|
+
output_columns,
|
151
|
+
offset,
|
152
|
+
limit,
|
153
|
+
calc_types,
|
154
|
+
calc_target)
|
155
|
+
labeled_drilldowns[label] = drilldown
|
156
|
+
end
|
157
|
+
labeled_drilldowns
|
158
|
+
end
|
159
|
+
|
160
|
+
class Drilldown < Struct.new(:keys,
|
161
|
+
:sort_keys,
|
162
|
+
:output_columns,
|
163
|
+
:offset,
|
164
|
+
:limit,
|
165
|
+
:calc_types,
|
166
|
+
:calc_target)
|
167
|
+
end
|
93
168
|
end
|
94
169
|
end
|
95
170
|
end
|
data/test/command/test-select.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2011-2013 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2011-2016 Kouhei Sutou <kou@clear-code.com>
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -43,6 +41,11 @@ class SelectCommandTest < Test::Unit::TestCase
|
|
43
41
|
query_expansion = "deprecated"
|
44
42
|
query_flags = "ALLOW_LEADING_NOT"
|
45
43
|
query_expander = "Terms.synonym"
|
44
|
+
adjuster = "tag * 10"
|
45
|
+
drilldown_calc_types = "MIN, MAX"
|
46
|
+
drilldown_calc_target = "age"
|
47
|
+
sort_keys = "-_score"
|
48
|
+
drilldown_sort_keys = "-_nsubrecs"
|
46
49
|
|
47
50
|
ordered_arguments = [
|
48
51
|
table,
|
@@ -64,6 +67,11 @@ class SelectCommandTest < Test::Unit::TestCase
|
|
64
67
|
query_expansion,
|
65
68
|
query_flags,
|
66
69
|
query_expander,
|
70
|
+
adjuster,
|
71
|
+
drilldown_calc_types,
|
72
|
+
drilldown_calc_target,
|
73
|
+
sort_keys,
|
74
|
+
drilldown_sort_keys,
|
67
75
|
]
|
68
76
|
command = select_command({}, ordered_arguments)
|
69
77
|
|
@@ -87,6 +95,11 @@ class SelectCommandTest < Test::Unit::TestCase
|
|
87
95
|
:query_expansion => query_expansion,
|
88
96
|
:query_flags => query_flags,
|
89
97
|
:query_expander => query_expander,
|
98
|
+
:adjuster => adjuster,
|
99
|
+
:drilldown_calc_types => drilldown_calc_types,
|
100
|
+
:drilldown_calc_target => drilldown_calc_target,
|
101
|
+
:sort_keys => sort_keys,
|
102
|
+
:drilldown_sort_keys => drilldown_sort_keys,
|
90
103
|
},
|
91
104
|
command.arguments)
|
92
105
|
end
|
@@ -126,4 +139,81 @@ class SelectCommandTest < Test::Unit::TestCase
|
|
126
139
|
command.conditions)
|
127
140
|
end
|
128
141
|
end
|
142
|
+
|
143
|
+
class SortKeysTest < self
|
144
|
+
def test_reader
|
145
|
+
command = select_command(:sort_keys => "-_score,_key")
|
146
|
+
assert_equal(["-_score", "_key"],
|
147
|
+
command.sort_keys)
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_sortby
|
151
|
+
command = select_command(:sortby => "-_score,_key")
|
152
|
+
assert_equal(["-_score", "_key"],
|
153
|
+
command.sort_keys)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
class DrilldownSortKeysTest < self
|
158
|
+
def test_reader
|
159
|
+
command = select_command(:drilldown_sort_keys => "-_nsubrecs,_key")
|
160
|
+
assert_equal(["-_nsubrecs", "_key"],
|
161
|
+
command.drilldown_sort_keys)
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_sortby
|
165
|
+
command = select_command(:drilldown_sortby => "-_nsubrecs,_key")
|
166
|
+
assert_equal(["-_nsubrecs", "_key"],
|
167
|
+
command.drilldown_sort_keys)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
class LabeledDrilldownsTest < self
|
172
|
+
def test_multiple
|
173
|
+
parameters = {
|
174
|
+
"drilldowns[tag].keys" => "tag",
|
175
|
+
"drilldowns[tag].sort_keys" => "-_nsubrecs,_key",
|
176
|
+
"drilldowns[tag].output_columns" => "_key,_nsubrecs,_min,_max",
|
177
|
+
"drilldowns[tag].offset" => "1",
|
178
|
+
"drilldowns[tag].limit" => "10",
|
179
|
+
"drilldowns[tag].calc_types" => "MIN,MAX",
|
180
|
+
"drilldowns[tag].calc_target" => "_nsubrecs",
|
181
|
+
|
182
|
+
"drilldowns[author_tag].keys" => "author,tag",
|
183
|
+
"drilldowns[author_tag].sort_keys" => "_value.author",
|
184
|
+
"drilldowns[author_tag].output_columns" => "_value.author,_nsubrecs",
|
185
|
+
}
|
186
|
+
command = select_command(parameters)
|
187
|
+
drilldowns = {
|
188
|
+
"author_tag" => drilldown(:keys => ["author", "tag"],
|
189
|
+
:sort_keys => ["_value.author"],
|
190
|
+
:output_columns => [
|
191
|
+
"_value.author",
|
192
|
+
"_nsubrecs",
|
193
|
+
]),
|
194
|
+
"tag" => drilldown(:keys => ["tag"],
|
195
|
+
:sort_keys => ["-_nsubrecs", "_key"],
|
196
|
+
:output_columns => [
|
197
|
+
"_key",
|
198
|
+
"_nsubrecs",
|
199
|
+
"_min",
|
200
|
+
"_max",
|
201
|
+
],
|
202
|
+
:offset => 1,
|
203
|
+
:limit => 10,
|
204
|
+
:calc_types => ["MIN", "MAX"],
|
205
|
+
:calc_target => "_nsubrecs"),
|
206
|
+
}
|
207
|
+
assert_equal(drilldowns,
|
208
|
+
command.labeled_drilldowns)
|
209
|
+
end
|
210
|
+
|
211
|
+
def drilldown(parameters)
|
212
|
+
drilldown = Groonga::Command::Select::Drilldown.new
|
213
|
+
parameters.each do |key, value|
|
214
|
+
drilldown[key] = value
|
215
|
+
end
|
216
|
+
drilldown
|
217
|
+
end
|
218
|
+
end
|
129
219
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groonga-command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -266,55 +266,54 @@ specification_version: 4
|
|
266
266
|
summary: Groonga-command is a library that represents [Groonga](http://groonga.org/)'s
|
267
267
|
command. You can write a program that handle Groonga's command by using groonga-command.
|
268
268
|
test_files:
|
269
|
-
- test/command
|
270
|
-
- test/command/test-
|
271
|
-
- test/command/test-range-filter.rb
|
272
|
-
- test/command/test-object-inspect.rb
|
273
|
-
- test/command/test-column-copy.rb
|
274
|
-
- test/command/test-io-flush.rb
|
275
|
-
- test/command/test-log-put.rb
|
276
|
-
- test/command/test-plugin-unregister.rb
|
277
|
-
- test/command/test-table-remove.rb
|
278
|
-
- test/command/test-column-rename.rb
|
279
|
-
- test/command/test-column-create.rb
|
280
|
-
- test/command/test-select.rb
|
281
|
-
- test/command/test-shutdown.rb
|
269
|
+
- test/groonga-command-test-utils.rb
|
270
|
+
- test/command/test-config-delete.rb
|
282
271
|
- test/command/test-object-remove.rb
|
283
|
-
- test/command/test-logical-select.rb
|
284
272
|
- test/command/test-table-tokenize.rb
|
285
|
-
- test/command/test-
|
286
|
-
- test/command/test-
|
287
|
-
- test/command/test-
|
288
|
-
- test/command/test-request-cancel.rb
|
289
|
-
- test/command/test-query-expand.rb
|
290
|
-
- test/command/test-log-level.rb
|
291
|
-
- test/command/test-table-list.rb
|
292
|
-
- test/command/test-column-list.rb
|
293
|
-
- test/command/test-load.rb
|
294
|
-
- test/command/test-dump.rb
|
295
|
-
- test/command/test-truncate.rb
|
296
|
-
- test/command/test-delete.rb
|
297
|
-
- test/command/test-ruby-load.rb
|
298
|
-
- test/command/test-plugin-register.rb
|
273
|
+
- test/command/test-reindex.rb
|
274
|
+
- test/command/test-plugin-unregister.rb
|
275
|
+
- test/command/test-io-flush.rb
|
299
276
|
- test/command/test-base.rb
|
300
|
-
- test/command/test-table-rename.rb
|
301
|
-
- test/command/test-config-get.rb
|
302
277
|
- test/command/test-logical-count.rb
|
278
|
+
- test/command/test-table-rename.rb
|
279
|
+
- test/command/test-column-rename.rb
|
280
|
+
- test/command/test-dump.rb
|
303
281
|
- test/command/test-normalize.rb
|
304
|
-
- test/command/test-
|
305
|
-
- test/command/test-
|
282
|
+
- test/command/test-config-get.rb
|
283
|
+
- test/command/test-register.rb
|
284
|
+
- test/command/test-shutdown.rb
|
285
|
+
- test/command/test-delete.rb
|
286
|
+
- test/command/test-column-copy.rb
|
287
|
+
- test/command/test-tokenize.rb
|
288
|
+
- test/command/test-log-put.rb
|
289
|
+
- test/command/test-load.rb
|
290
|
+
- test/command/test-column-list.rb
|
291
|
+
- test/command/test-plugin-register.rb
|
292
|
+
- test/command/test-request-cancel.rb
|
293
|
+
- test/command/test-column-create.rb
|
294
|
+
- test/command/test-config-set.rb
|
306
295
|
- test/command/test-logical-range-filter.rb
|
307
|
-
- test/command/test-
|
308
|
-
- test/command/test-logical-table-remove.rb
|
296
|
+
- test/command/test-object-inspect.rb
|
309
297
|
- test/command/format/test-command.rb
|
310
|
-
- test/command/test-
|
298
|
+
- test/command/test-logical-select.rb
|
299
|
+
- test/command/test-get.rb
|
311
300
|
- test/command/test-thread-limit.rb
|
312
|
-
- test/command/test-
|
313
|
-
- test/command/test-
|
314
|
-
- test/command/test-
|
301
|
+
- test/command/test-table-list.rb
|
302
|
+
- test/command/test-object-exist.rb
|
303
|
+
- test/command/test-log-level.rb
|
304
|
+
- test/command/test-range-filter.rb
|
315
305
|
- test/command/test-status.rb
|
316
|
-
- test/command/test-
|
306
|
+
- test/command/test-logical-shard-list.rb
|
307
|
+
- test/command/test-schema.rb
|
308
|
+
- test/command/test-suggest.rb
|
309
|
+
- test/command/test-select.rb
|
310
|
+
- test/command/test-column-remove.rb
|
311
|
+
- test/command/test-ruby-eval.rb
|
317
312
|
- test/command/test-table-create.rb
|
313
|
+
- test/command/test-table-remove.rb
|
314
|
+
- test/command/test-ruby-load.rb
|
315
|
+
- test/command/test-table-copy.rb
|
316
|
+
- test/command/test-query-expand.rb
|
317
|
+
- test/command/test-truncate.rb
|
318
|
+
- test/command/test-logical-table-remove.rb
|
318
319
|
- test/run-test.rb
|
319
|
-
- test/groonga-command-test-utils.rb
|
320
|
-
has_rdoc:
|