码迷,mamicode.com
首页 > Windows程序 > 详细

Solrj API读取core 索引库数据

时间:2015-08-18 19:13:14      阅读:194      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!