public static void main(String[] args) throws Exception{
        String s = "::sfas*^&";
        s = ClientUtils.escapeQueryChars(s);
        System.out.println(s);

        HttpSolrClient server = new HttpSolrClient("http://");
        SolrQuery query = new SolrQuery();
        //查询内容
        query.setQuery("R:运算");

        //条件
        query.setFilterQueries("CO:");
        //设置返回字段
        query.setFields("Row,CON,PA");
        query.setSort("SEQ", SolrQuery.ORDER.asc);

        //返回结果从第几条开始
        //query.setStart(0);
        //query.setRows(10);
        QueryResponse queryResponse = server.query(query);
        SolrDocumentList docs = queryResponse.getResults();
        System.out.println(docs.size());
        for(int i=0;i<docs.size();i++){
            System.out.println(docs.get(i));
            System.out.println(docs.get(i).getFieldValue("CON"));
        }

        //总数
        System.out.println(queryResponse.getResults().getNumFound());
        server.commit();
        server.close();

    }

 

posted on 2018-07-13 09:27  充实自己  阅读(130)  评论(0编辑  收藏  举报