ej 0.0.4 → 0.0.5
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/lib/ej/commands.rb +12 -9
- data/lib/ej/core.rb +11 -6
- data/lib/ej/version.rb +1 -1
- metadata +2 -3
- data/contrib/completion/_ej +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0d23dab3ff243a967dac0c83855aec202e66335
|
4
|
+
data.tar.gz: 512d2f7a5191fda2bda9c825e7eadcf435457c27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41ffacc81eb4bdb1bdbea0cc2c9b6acade8f3f88ca1185fd07bdf778c35abea78a5058aa0f4d7b4c852f3dc0458addfabdbf7ce688223fa4feca205f1662d9b1
|
7
|
+
data.tar.gz: 3e34edf2b15359fc9b4f4729c55006fa40a5ff92dd399489fc0f89ab01b993c74fbae42b6c8400268133baecfbb3bd11db291a73a843ebf730228ebdd5c0fca6
|
data/lib/ej/commands.rb
CHANGED
@@ -18,7 +18,8 @@ module Ej
|
|
18
18
|
class_option :profile, aliases: '-p', type: :string, default: 'default', desc: 'profile by .ejrc'
|
19
19
|
class_option :debug, aliases: '-d', type: :string, default: false, desc: 'debug mode'
|
20
20
|
map '-s' => :search
|
21
|
-
map '-
|
21
|
+
map '-f' => :facet
|
22
|
+
map '-c' => :count
|
22
23
|
map '-I' => :bulk
|
23
24
|
map '-l' => :indices
|
24
25
|
map '-a' => :aliases
|
@@ -54,12 +55,19 @@ module Ej
|
|
54
55
|
puts_json(@core.search(options['type'], query, options['size'], options['from'], options['source_only']))
|
55
56
|
end
|
56
57
|
|
57
|
-
desc 'total [lucene query]', '
|
58
|
+
desc 'total [lucene query]', 'total'
|
58
59
|
option :type, type: :string, aliases: '-t', default: nil, desc: 'type'
|
59
|
-
def
|
60
|
+
def count(query = nil)
|
60
61
|
puts_json(@core.search(options['type'], query, 0, 0, false))
|
61
62
|
end
|
62
63
|
|
64
|
+
desc 'distinct [lucene query]', 'distinct'
|
65
|
+
option :type, type: :string, aliases: '-t', default: nil, desc: 'type'
|
66
|
+
option :query, type: :string, aliases: '-q', default: nil, desc: 'query'
|
67
|
+
def distinct(term)
|
68
|
+
puts_json(@core.distinct(term, options['type'], options['query']))
|
69
|
+
end
|
70
|
+
|
63
71
|
desc 'move', 'move index'
|
64
72
|
option :source, type: :string, aliases: '--source', required: true, desc: 'source host'
|
65
73
|
option :dest, type: :string, aliases: '--dest', required: true, desc: 'dest host'
|
@@ -74,7 +82,7 @@ module Ej
|
|
74
82
|
@core.dump(options['query'])
|
75
83
|
end
|
76
84
|
|
77
|
-
desc '-
|
85
|
+
desc '-f', 'facet'
|
78
86
|
option :query, type: :string, aliases: '-q', default: '*', desc: 'query'
|
79
87
|
option :size, type: :numeric, aliases: '-n', default: 10, desc: 'size'
|
80
88
|
def facet(term)
|
@@ -123,11 +131,6 @@ module Ej
|
|
123
131
|
puts_json(@core.indices)
|
124
132
|
end
|
125
133
|
|
126
|
-
desc 'count', 'count'
|
127
|
-
def count
|
128
|
-
puts_json(@core.count)
|
129
|
-
end
|
130
|
-
|
131
134
|
desc 'stats', 'count'
|
132
135
|
def stats
|
133
136
|
puts_json(@core.stats)
|
data/lib/ej/core.rb
CHANGED
@@ -24,6 +24,12 @@ module Ej
|
|
24
24
|
source_only ? get_sources(results) : results
|
25
25
|
end
|
26
26
|
|
27
|
+
def distinct(term, type, query)
|
28
|
+
body = { size: 0, "aggs"=>{ term + "_count"=>{"cardinality"=>{"field"=>term}}}}
|
29
|
+
body[:query] = { query_string: { query: query } } unless query.nil?
|
30
|
+
@client.search index: @index, type: type, body: body
|
31
|
+
end
|
32
|
+
|
27
33
|
def move(source, dest, query)
|
28
34
|
per = 30000
|
29
35
|
source_client = Elasticsearch::Client.new hosts: source, index: @index, logger: @logger
|
@@ -34,11 +40,14 @@ module Ej
|
|
34
40
|
body = { size: per, from: from }
|
35
41
|
body[:query] = { query_string: { query: query } } unless query.nil?
|
36
42
|
data = Hashie::Mash.new(source_client.search index: @index, body: body)
|
43
|
+
p data.hits.hits.size
|
37
44
|
break if data.hits.hits.empty?
|
38
45
|
bulk_message = []
|
39
46
|
data.hits.hits.each do |doc|
|
40
|
-
|
41
|
-
|
47
|
+
source = doc.delete('_source')
|
48
|
+
doc.delete('_score')
|
49
|
+
bulk_message << { index: doc.to_h }
|
50
|
+
bulk_message << source
|
42
51
|
end
|
43
52
|
dest_client.bulk body: bulk_message unless bulk_message.empty?
|
44
53
|
num += 1
|
@@ -116,10 +125,6 @@ module Ej
|
|
116
125
|
@client.cat.indices format: 'json'
|
117
126
|
end
|
118
127
|
|
119
|
-
def count
|
120
|
-
@client.cat.count index: @index, format: 'json'
|
121
|
-
end
|
122
|
-
|
123
128
|
def stats
|
124
129
|
@client.indices.stats index: @index
|
125
130
|
end
|
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.0.
|
4
|
+
version: 0.0.5
|
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-
|
11
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -151,7 +151,6 @@ files:
|
|
151
151
|
- README.md
|
152
152
|
- Rakefile
|
153
153
|
- bin/ej
|
154
|
-
- contrib/completion/_ej
|
155
154
|
- ej.gemspec
|
156
155
|
- lib/ej.rb
|
157
156
|
- lib/ej/commands.rb
|
data/contrib/completion/_ej
DELETED