ej 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ej/commands.rb +3 -8
- data/lib/ej/core.rb +31 -11
- data/lib/ej/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 643e3d4fc75c7f83f484f89845d0fcf4b75433a1
|
4
|
+
data.tar.gz: d65079cd2e20a88ba694ad20d8ee8db48d50df24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeb5afcd34843b5caef5d53a408d05a42f2a4a5db6367198bf6ff6ce17c6c14fe224dbd460c123e7a2fd885506929835044056f450d61b632e008378f09083b9
|
7
|
+
data.tar.gz: a47937f3958993b8809c537c2b381da730de01a82b96918ff6cf8677ce46661ee64bfc84d49a927113d6f9d9cc10f382f3f0907f2bd3152395eade6d3595a82c
|
data/lib/ej/commands.rb
CHANGED
@@ -20,7 +20,6 @@ module Ej
|
|
20
20
|
map '-a' => :aliases
|
21
21
|
map '-m' => :mapping
|
22
22
|
map '-e' => :debug_eval
|
23
|
-
map '--j2h' => :json_to_hash
|
24
23
|
map '--health' => :health
|
25
24
|
|
26
25
|
def initialize(args = [], options = {}, config = {})
|
@@ -98,8 +97,9 @@ module Ej
|
|
98
97
|
desc 'aggs', 'aggs'
|
99
98
|
option :query, type: :string, aliases: '-q', default: '*', desc: 'query'
|
100
99
|
option :size, type: :numeric, aliases: '-n', default: 10, desc: 'size'
|
101
|
-
|
102
|
-
|
100
|
+
option :terms, type: :array, aliases: '-t', required: true, desc: 'size'
|
101
|
+
def aggs
|
102
|
+
puts_with_format(@core.aggs(options['terms'], options['size'], options['query']))
|
103
103
|
end
|
104
104
|
|
105
105
|
desc 'min', 'term'
|
@@ -232,11 +232,6 @@ module Ej
|
|
232
232
|
puts_with_format @core.nodes_stats
|
233
233
|
end
|
234
234
|
|
235
|
-
desc '--j2h', 'json to hash'
|
236
|
-
def json_to_hash
|
237
|
-
pp Yajl::Parser.parse(STDIN.read)
|
238
|
-
end
|
239
|
-
|
240
235
|
private
|
241
236
|
|
242
237
|
def puts_with_format(object)
|
data/lib/ej/core.rb
CHANGED
@@ -116,17 +116,37 @@ module Ej
|
|
116
116
|
@client.search index: @index, body: body
|
117
117
|
end
|
118
118
|
|
119
|
-
def aggs(
|
120
|
-
body = {
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
119
|
+
def aggs(terms, size, query)
|
120
|
+
body = {
|
121
|
+
"size"=>0,
|
122
|
+
"query"=>{
|
123
|
+
"query_string"=>{
|
124
|
+
"query"=>query
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
agg_terms = []
|
130
|
+
code = %Q{['aggs']}
|
131
|
+
terms.each_with_index do |term, i|
|
132
|
+
term_name = "agg_#{term}"
|
133
|
+
aggs_body = {
|
134
|
+
term_name=>{
|
135
|
+
"terms"=>{
|
136
|
+
"field"=>term,
|
137
|
+
"size"=>size,
|
138
|
+
"order"=>{
|
139
|
+
"_count"=>"desc"
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
eval(%Q{body#{code} = aggs_body})
|
146
|
+
code += %Q{['#{term_name}']['aggs']}
|
147
|
+
end
|
148
|
+
|
149
|
+
@client.search index: @index, body: body
|
130
150
|
end
|
131
151
|
|
132
152
|
def min(term)
|
data/lib/ej/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ej
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- toyama0919
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|