+def parse_fields(es_result)
- result_hash = {}
- es_result.each do |result|
- key = result['key']
- sub_field = result.keys.detect { |field| field.start_with?('all_') }
- if sub_field
all_field = result[sub_field]['buckets']
result_hash[key] = parse_fields(all_field)
- else
result_hash[key] = result['doc_count']
- end
above if-else-end => result_hash[key] = result['doc_count'] unless sub_field all_field = result[sub_field]['buckets'] result_hash[key] = parse_fields(all_field)
Thanks, Luan Shengde
- end
- result_hash
+end
2.23.0