首页 > Windows开发 > 详细

Solrj API读取core 索引库数据

时间:2015-08-18 19:12:32      阅读:347      评论:0      收藏:0      [点我收藏+]
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;

    }

 

Solrj API读取core 索引库数据

原文:http://www.cnblogs.com/zhanggl/p/4739929.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!