On Wed, Jan 13, 2021 at 10:56:07AM +0800, Lu Weitao wrote:
On Wed, Jan 13, 2021 at 10:52:03AM +0800, Luan Shengde wrote:
+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
if this, need "next" unless sub_field result_hash[key] = result['doc_count'] next end
forget this -_-||
Thanks, Luan Shengde
Thanks, Weitao
all_field = result[sub_field]['buckets'] result_hash[key] = parse_fields(all_field)
Thanks, Luan Shengde
- end
- result_hash
+end
2.23.0