bin/estool in wonderdog-0.1.1 vs bin/estool in wonderdog-0.2.0
- old
+ new
@@ -21,10 +21,13 @@
delete Delete the specified INDEX. Requires confirmation.
refresh Refresh the specified INDEX
optimize Optimizes the specified INDEX to (-s) number of segments
snapshot Snapshots the specified INDEX to the gateway
segments Returns the segment information. Requires ElasticSearch v
+ aliases Returns a list of Index/Alias pairs
+ ialiases Returns a list of Alias/Index pairs
+ count The number of documents in an index
mapping
set_replication
search
obj_types
@@ -87,11 +90,11 @@
puts display
end
def status() shell_response(File.join(options.index, "_status?")) ; end
- def list() status["indices"].keys ; end
+ def list() status["indices"].keys.sort ; end
def health() shell_response("_cluster/health?") ; end
def flush() shell_response(File.join(options.index, "_flush?full=true")) ; end
@@ -109,9 +112,27 @@
def snapshot() shell_response(File.join(options.index, "_gateway/snapshot"), "-XPOST") ; end
def segments() shell_response(File.join(options.index, "_segments")) ; end
def mapping() shell_response(File.join(options.index, "_mapping")) ; end
+
+ def aliases() shell_response('_aliases?').sort.inject({}){ |hsh, (index, info)| hsh[index] = info['aliases'].keys ; hsh } ; end
+
+ def ialiases()
+ inverse = Hash.new{ |hsh, key| hsh[key] = [] }
+ aliases.each{ |idx, als| als.each{ |a| inverse[a] << idx } }
+ inverse
+ end
+
+ # estool status -r | ruby -rjson -e 'puts JSON.parse($stdin.read)["indices"]["item_count_legacy"]["docs"]'
+ # {"num_docs"=>187749, "max_doc"=>187749, "deleted_docs"=>0}
+ def count()
+ if options.index == '_all'
+ status['indices'].inject({}){ |hsh, (index, info)| hsh[index] = info['docs']['num_docs'] ; hsh }
+ else
+ { options.index => shell_response(File.join(options.index, '_count'))['count'] }
+ end
+ end
# curl -s -XPUT http://host:port/index/_settings -d '{"index":{"number_of_replicas":num}}'
def set_replication() { "error" => "method not yet implemented" }; end
def search() shell_response(File.join(options.index, "_search?q=#{options.query}")) ; end