The data format obtained by the Elasticsearch-java API is in JSON format, as shown below
If you get a sum,avg value, the format will change.
Jsonobject obj =Json.parseobject (esresult.getstring ()); //Figure Alist<map<string,object>> list =NewArraylist<map<string,object>>(); Try{List<Map> hits = (list<map>) propertyutils.getnestedproperty (obj, "hits.hits"); if(hits! =NULL){ for(map json:hits) {map<string,object> span =NewHashmap<string,object>(); Map _SC= (MAP) json.get ("_source"); Span.put ("T_deviceip", _sc.get ("T_deviceip")); Span.put ("Cpupercent", _sc.get ("Cpupercent")); List.add (span); } } } Catch(Exception e) {//TODO auto-generated Catch blockE.printstacktrace (); } //Figure 2Jsonobject obj =Json.parseobject (esresult.getstring ()); List<map<string,object>> list =NewArraylist<map<string,object>>(); Try{List<Map> buckets = (list<map>) propertyutils.getnestedproperty (obj, "aggregations.ip.buckets"); for(map json:buckets) {map<string,object> span =NewHashmap<string,object>(); Span.put ("IP", Json.get ("Key")); }
Elasticsearch data obtained by Java processing