ej 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0d23dab3ff243a967dac0c83855aec202e66335
4
- data.tar.gz: 512d2f7a5191fda2bda9c825e7eadcf435457c27
3
+ metadata.gz: c6a06d5628b4e5d30dd820cf0059142022db16af
4
+ data.tar.gz: 4a1e3cbe19bd7a73f1a3a9d717a43c0b5c2d17b6
5
5
  SHA512:
6
- metadata.gz: 41ffacc81eb4bdb1bdbea0cc2c9b6acade8f3f88ca1185fd07bdf778c35abea78a5058aa0f4d7b4c852f3dc0458addfabdbf7ce688223fa4feca205f1662d9b1
7
- data.tar.gz: 3e34edf2b15359fc9b4f4729c55006fa40a5ff92dd399489fc0f89ab01b993c74fbae42b6c8400268133baecfbb3bd11db291a73a843ebf730228ebdd5c0fca6
6
+ metadata.gz: 668b2706ada7508073b8dee5e37d97991d7eb143f17dba84510d88dddfd82175342d0054a3a3d8b4206e17cc9a9b2b40a26605f6c1dce562f16c2b2dc54cbe9d
7
+ data.tar.gz: 4c0b9939592bae0dd2650a5e710c6faf8f0c0c9803d235c0249ece62b1a71f506a3f9d6b6cd6b620d380a5e172f3b77cc8d91b492fd6a375a57ff07a87fe1af6
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Ej
2
2
 
3
- elasticsearch utility
3
+ elasticsearch command line utility
4
+
5
+ required ruby version >= 2.0
4
6
 
5
7
  ## Installation
6
8
 
@@ -24,7 +26,7 @@ Or install it yourself as:
24
26
  ej -s
25
27
  ```
26
28
 
27
- ### other host
29
+ ### other host(default host is localhost)
28
30
  ```bash
29
31
  ej -s -h other_host
30
32
  ```
@@ -36,12 +38,17 @@ ej -s "ip_address: 127.0.0.1" -i logstash-2014.07.01
36
38
 
37
39
  ### index list
38
40
  ```bash
39
- ej -l
41
+ ej -l -h other_host
42
+ ```
43
+
44
+ ### count
45
+ ```bash
46
+ ej -c "log_date: 2014-01-15"
40
47
  ```
41
48
 
42
49
  ### facet
43
50
  ```bash
44
- ej -c ip_address -q "log_date: 2014-01-15"
51
+ ej -f session_id -q "log_date: 2014-01-15"
45
52
  ```
46
53
 
47
54
  ### mapping
@@ -49,6 +56,11 @@ ej -c ip_address -q "log_date: 2014-01-15"
49
56
  ej -m
50
57
  ```
51
58
 
59
+ ### delete index
60
+ ```bash
61
+ ej delete -i logstash-2014.07.01 -h other_host
62
+ ```
63
+
52
64
 
53
65
  ## Contributing
54
66
 
data/ej.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["toyama0919@gmail.com"]
11
11
  spec.summary = %q{Command-line Elasticsearch TO JSON processor.}
12
12
  spec.description = %q{Command-line Elasticsearch TO JSON processor.}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/toyama0919/ej"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
data/lib/ej/commands.rb CHANGED
@@ -8,14 +8,10 @@ require 'active_support/core_ext/array'
8
8
  require 'active_support/core_ext/string'
9
9
  require 'logger'
10
10
 
11
- USER_SETTING_FILE = "#{ENV['HOME']}/.ejrc"
12
- CURRENT_SETTING_FILE = ".ejrc"
13
-
14
11
  module Ej
15
12
  class Commands < Thor
16
13
  class_option :index, aliases: '-i', type: :string, default: '_all', desc: 'index'
17
14
  class_option :host, aliases: '-h', type: :string, default: 'localhost', desc: 'host'
18
- class_option :profile, aliases: '-p', type: :string, default: 'default', desc: 'profile by .ejrc'
19
15
  class_option :debug, aliases: '-d', type: :string, default: false, desc: 'debug mode'
20
16
  map '-s' => :search
21
17
  map '-f' => :facet
@@ -34,18 +30,6 @@ module Ej
34
30
  @core = Ej::Core.new(@global_options['host'], @global_options['index'], @global_options['debug'])
35
31
  end
36
32
 
37
- desc 'init', 'init'
38
- def init
39
- setting_file_path = "#{ENV['HOME']}/.ejrc"
40
- default = {}
41
- default['default'] = {}
42
- default['default']['host'] = ask("What is default host?", default: 'localhost')
43
- default['default']['port'] = ask("What is default port?", default: 9200)
44
- default['default']['index'] = ask("What is default index?", default: '_all')
45
- File.write(setting_file_path, default.to_yaml)
46
- say("save setting file #{setting_file_path}", :green)
47
- end
48
-
49
33
  desc '-s [lucene query]', 'search'
50
34
  option :type, type: :string, aliases: '-t', default: nil, desc: 'type'
51
35
  option :size, type: :numeric, aliases: '-n', default: 10, desc: 'size'
@@ -121,27 +105,27 @@ module Ej
121
105
  puts_json(@core.aliases)
122
106
  end
123
107
 
124
- desc 'state', 'health'
108
+ desc 'state', 'state'
125
109
  def state
126
110
  puts_json(@core.state)
127
111
  end
128
112
 
129
- desc 'indices', 'indices'
113
+ desc 'indices', 'show indices summary'
130
114
  def indices
131
115
  puts_json(@core.indices)
132
116
  end
133
117
 
134
- desc 'stats', 'count'
118
+ desc 'stats', 'index stats'
135
119
  def stats
136
120
  puts_json(@core.stats)
137
121
  end
138
122
 
139
- desc 'mapping', 'count'
123
+ desc 'mapping', 'show mapping'
140
124
  def mapping
141
125
  puts_json(@core.mapping)
142
126
  end
143
127
 
144
- desc 'not_analyzed', 'not_analyzed'
128
+ desc 'not_analyzed', 'not analyzed'
145
129
  def not_analyzed
146
130
  json = File.read(File.expand_path('../../../template/not_analyze_template.json', __FILE__))
147
131
  hash = Yajl::Parser.parse(json)
@@ -157,15 +141,15 @@ module Ej
157
141
  puts_json(@core.put_mapping(options['index'], options['type'], body))
158
142
  end
159
143
 
160
- desc 'put_template', 'put_template'
144
+ desc 'put_template', 'put template'
161
145
  def put_template(name)
162
146
  hash = Yajl::Parser.parse(STDIN.read)
163
147
  puts_json(@core.put_template(name, hash))
164
148
  end
165
149
 
166
- desc 'create_aliases', 'create_aliases'
167
- option :alias, type: :string, aliases: '-a', default: nil, required: true, desc: 'type'
168
- option :indices, type: :array, aliases: '-x', default: nil, required: true, desc: 'type'
150
+ desc 'create_aliases', 'create aliases'
151
+ option :alias, type: :string, aliases: '-a', default: nil, required: true, desc: 'alias name'
152
+ option :indices, type: :array, aliases: '-x', default: nil, required: true, desc: 'index array'
169
153
  def create_aliases
170
154
  @core.create_aliases(options['alias'], options['indices'])
171
155
  end
@@ -175,11 +159,12 @@ module Ej
175
159
  @core.recovery
176
160
  end
177
161
 
178
- desc 'delete', 'delete index'
179
- option :index, aliases: '-i', type: :string, default: nil, required: true, desc: 'profile by .database.yml'
162
+ desc 'delete', 'delete'
163
+ option :index, aliases: '-i', type: :string, default: nil, required: true, desc: 'index'
164
+ option :type, type: :string, aliases: '-t', default: nil, desc: 'type'
180
165
  option :query, type: :string, aliases: '-q', default: nil, desc: 'query'
181
166
  def delete
182
- @core.delete(options['index'], options['query'])
167
+ @core.delete(options['index'], options['type'], options['query'])
183
168
  end
184
169
 
185
170
  desc 'delete_template --name [name]', 'delete_template'
@@ -188,22 +173,22 @@ module Ej
188
173
  @core.delete_template(options['name'])
189
174
  end
190
175
 
191
- desc 'template', 'get template'
176
+ desc 'template', 'show template'
192
177
  def template
193
178
  puts_json(@core.template)
194
179
  end
195
180
 
196
- desc 'settings', 'get template'
181
+ desc 'settings', 'show template'
197
182
  def settings
198
183
  puts_json(@core.settings)
199
184
  end
200
185
 
201
- desc 'warmer', 'get warmer'
186
+ desc 'warmer', 'warmer'
202
187
  def warmer
203
188
  puts_json(@core.warmer)
204
189
  end
205
190
 
206
- desc 'refresh', 'get refresh'
191
+ desc 'refresh', 'refresh'
207
192
  def refresh
208
193
  puts_json(@core.refresh)
209
194
  end
@@ -219,15 +204,5 @@ module Ej
219
204
  puts Yajl::Encoder.encode(object)
220
205
  end
221
206
 
222
- def setting
223
- if File.exist?(CURRENT_SETTING_FILE)
224
- return YAML.load_file(CURRENT_SETTING_FILE)
225
- end
226
-
227
- if File.exist?(USER_SETTING_FILE)
228
- return YAML.load_file(USER_SETTING_FILE)
229
- end
230
- return { host: 'localhost', index: '_all', port: 9200 }
231
- end
232
207
  end
233
208
  end
data/lib/ej/core.rb CHANGED
@@ -157,11 +157,15 @@ module Ej
157
157
  @client.indices.recovery index: @index
158
158
  end
159
159
 
160
- def delete(index, query)
160
+ def delete(index, type, query)
161
161
  if query.nil?
162
- @client.indices.delete index: index
162
+ if type.nil?
163
+ @client.indices.delete index: index
164
+ else
165
+ @client.delete_by_query index: index, type: type, q: '*'
166
+ end
163
167
  else
164
- @client.delete_by_query index: index, q: query
168
+ @client.delete_by_query index: index, type: type, q: query
165
169
  end
166
170
  end
167
171
 
data/lib/ej/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ej
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
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.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - toyama0919
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-22 00:00:00.000000000 Z
11
+ date: 2014-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -158,7 +158,7 @@ files:
158
158
  - lib/ej/version.rb
159
159
  - template/ejrc.erb
160
160
  - template/not_analyze_template.json
161
- homepage: ''
161
+ homepage: https://github.com/toyama0919/ej
162
162
  licenses:
163
163
  - MIT
164
164
  metadata: {}
@@ -183,3 +183,4 @@ signing_key:
183
183
  specification_version: 4
184
184
  summary: Command-line Elasticsearch TO JSON processor.
185
185
  test_files: []
186
+ has_rdoc: