标签:
public static Map<String, Object> solrCloudR() throws Exception { Map<String, Object> mapResult = new HashMap<String, Object>(); String zkHost = "ip:2181"; CloudSolrServer solrServer = new CloudSolrServer(zkHost); solrServer.setDefaultCollection("collection1"); SolrQuery solrQuery = new SolrQuery(); solrQuery.set("q", "*:*"); QueryResponse response = solrServer.query(solrQuery); SolrDocumentList results = response.getResults(); response.getResults().getNumFound(); mapResult.put("results:", results); mapResult.put("resultNums", response.getResults().getNumFound()); for (SolrDocument solrDocument: results){ Collection<String> fieldNames = solrDocument.getFieldNames(); for(String lists:fieldNames){ Object object = solrDocument.get(lists); System.out.println("fields:"+object); } } System.out.println(results.size()); return mapResult; }
标签:
原文地址:http://www.cnblogs.com/zhanggl/p/4739929.html