Solr的学习使用之(八)facet实战
2014-01-19 23:59
441 查看
以下为统计media的数量功能,通过solrj,采用了facet方法,类似于sql的分组group by查询;这边的代码只是获取总媒体数量,其实他还有其他功能,去循环solrList的话,可以获取各个媒体的数量
public int getMediaCount(Keyword keyword) { HttpSolrServer solrServer = SolrServer.getInstance().getServer(); SolrQuery sQuery = new SolrQuery(); int result = 0; try { String para = this.initKeywordQueryPara(keyword);//这边的值大概是酱紫的 "* AND publishTime:[1360000 TO 13700000] AND contentStr:\"关键字\""; sQuery.setFacet(true); sQuery.setFacetMinCount(1); sQuery.addFacetField("channelName"); sQuery.setQuery(para); QueryResponse response = solrServer.query(sQuery,SolrRequest.METHOD.POST); List<Count> solrList = response.getFacetField("channelName").getValues(); result = solrList.size(); return result; } catch (SolrServerException e) { log.error("查询solr失败", e); e.printStackTrace(); } finally{ solrServer.shutdown(); solrServer = null; } return result; }
相关文章推荐
- Solr的学习使用之(九)facet.pivot实战
- 转:Solr学习总结-Facet(各种例子,包括facet.query的使用)
- Solr的学习使用之(七)Solr高级查询facet、facet.pivot简介
- Solr的学习使用之(七)Solr高级查询facet、facet.pivot简介 - OnTheRoad_Lee
- Solr的学习使用之(三)IKAnalyzer中文分词器的配置
- 《Flex 4实战》学习笔记:CH15 使用数据服务
- swift学习六天 项目实战-知乎日报之UITabelView使用
- 指尖上的电商---(8)Solr中Facet的使用方法
- 机器学习实战——使用K-近邻算法进行约会配对
- 小白学习Rxjava2,从零开始到实战(一) RxJava2的基础使用
- (转)Django ====> 实战学习篇十三 分页(Paginator)处理;Django使用内置的admin
- solr学习之路 配置文件的讲解以及页面客户端的使用 <二>
- 获取版本号完成版本更新的过程步骤方法流程及Xutils的使用(项目实战学习总结)
- 第10课:底实战详解使用Java开发Spark程序学习笔记(二)
- 第59课:使用Java和Scala在IDE中实战RDD和DataFrame转换操作’学习笔记
- 机器学习实战 - 读书笔记(12) - 使用FP-growth算法来高效发现频繁项集
- Solr学习总结(八)IK 中文分词的配置和使用
- Solr学习总结-Facet
- Solr实战:使用Hue+Solr实现标签查询
- Scala学习第四天 Scala的For与Function进阶实战、Lazy的使用