[英]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);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.