ej 0.0.4 → 0.0.5

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: 0ce4928c5040658e1671941f3a3e7091895098b4
4
- data.tar.gz: c57ecc1f55a53acc4ea546244d5be96aea4d4ca5
3
+ metadata.gz: a0d23dab3ff243a967dac0c83855aec202e66335
4
+ data.tar.gz: 512d2f7a5191fda2bda9c825e7eadcf435457c27
5
5
  SHA512:
6
- metadata.gz: 6705c528ab2e663560dc5d24e470fc0fa5396ef89840fe2cecb4c20b2aba69f7db3d33d33f518617018e6c52d95ae7a37cf40cf8a1500201280a4659987fc2d3
7
- data.tar.gz: f36e354799a3b42370f45005ad2827dfa9f1f674ddfcc6ded150736a5086761ac5729b2aff28e2e1a049355c01f4fc1bdf59ccfb71a68702ac2ff3cd55ae807f
6
+ metadata.gz: 41ffacc81eb4bdb1bdbea0cc2c9b6acade8f3f88ca1185fd07bdf778c35abea78a5058aa0f4d7b4c852f3dc0458addfabdbf7ce688223fa4feca205f1662d9b1
7
+ data.tar.gz: 3e34edf2b15359fc9b4f4729c55006fa40a5ff92dd399489fc0f89ab01b993c74fbae42b6c8400268133baecfbb3bd11db291a73a843ebf730228ebdd5c0fca6
@@ -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 '-c' => :facet
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]', 'search'
58
+ desc 'total [lucene query]', 'total'
58
59
  option :type, type: :string, aliases: '-t', default: nil, desc: 'type'
59
- def total(query = nil)
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 '-c', 'facet'
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)
@@ -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
- bulk_message << { 'index' => { '_index' => doc._index, '_type' => doc._type, '_id' => doc._id } }
41
- bulk_message << doc._source
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
@@ -1,3 +1,3 @@
1
1
  module Ej
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
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.4
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-07 00:00:00.000000000 Z
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
@@ -1,3 +0,0 @@
1
- #compdef myq
2
-
3
- compadd `ej help | grep myq | cut -d " " -f 3-4`