es-find support order result by keyword with desc
[Example] es-find suite=iperf -d/--desc-keyword start_time
Signed-off-by: Lu Weitao luweitaobe@163.com --- sbin/es-find | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sbin/es-find b/sbin/es-find index 2397338..985fdea 100755 --- a/sbin/es-find +++ b/sbin/es-find @@ -31,6 +31,8 @@ end
options = {} options[:nr_jobs] = 10 +options[:desc_keyword] = nil + opt_parser = OptionParser.new do |opts| opts.banner = 'Usage: es-find [options] search_key1=val1[,val2..] ..'
@@ -45,6 +47,10 @@ opt_parser = OptionParser.new do |opts| options[:nr_jobs] = n.to_i end
+ opts.on('-d', '--desc-keyword KEYWORD', 'order by keyword: start_time|end_time|...') do |d| + options[:desc_keyword] = d + end + opts.on_tail('-h', '--help', 'show this message') do puts opts exit @@ -54,6 +60,6 @@ end opt_parser.parse!(ARGV) items = parse_argv es = ESQuery.new(ES_HOST, ES_PORT) -query_result = es.multi_field_query(items, size: options[:nr_jobs]) +query_result = es.multi_field_query(items, size: options[:nr_jobs], desc_keyword: options[:desc_keyword]) json_string = JSON.pretty_generate(query_result) puts json_string