如何从 solr 中获取分片中的结果并将其存储在 hashmap 数组中

How to get no of results in shards from solr and store in hashmap array

我有来自 solr 的 resp.getResponse().get("shards.info") 响应数据如下:

 {
xyz1={

     numFound=149040,
     maxScore=1.0,
     shardAddress=http://xyz1,
     time=3
},

xyz2={
     numFound=12414,
     maxScore=1.0,
     shardAddress=http://xyz2,
     time=5
},

xyz3={
     numFound=62175,
     maxScore=1.0,
     shardAddress=http://xyz13,
     time=6
},

xyz4={
     numFound=200572,
     maxScore=1.0,
     shardAddress=http://xyz14,
     time=4
},

xyz5={
     numFound=32853,
     maxScore=1.0,
     shardAddress=http://xyz5,
     time=5
},

xyz6={
     numFound=73443,
     maxScore=1.0,
     shardAddress=http://xyz6,
     time=5
}
 }
        for (SolrDocument solrDocument:resp.getResponse().get("shards.info")) 
        { 
            documentsList.add(solrDocument);
        }


 but found this error "Can only iterate over an array or an instance of java.lang.Iterable"
How to pass those values into documentsList_shards please help me

希望对一些人有所帮助,如果有改进请不客气

    NamedList<Object> report = (NamedList<Object>)resp.getResponse().get("shards.info");
    Iterator<Map.Entry<String, Object>> coreIterator = report.iterator();
    HashMap<String, String> hm = new HashMap<String, String>(); 
    while(coreIterator.hasNext())
    {
        Map.Entry<String, Object> core = coreIterator.next();
        String core_name=(core.getKey().toString()).replace("abcc","");
        NamedList<Object> report_in = (NamedList<Object>)core.getValue();
        Iterator<Map.Entry<String, Object>> coreIterator_in = report_in.iterator();
        while(coreIterator_in.hasNext()){
            Map.Entry<String, Object> core_in = coreIterator_in.next();
            if(core_in.getKey().equals("numFound"))
            {
                String numFound=core_in.getValue().toString();
                hm.put(core_name, numFound); 
            }
        }
    }