solr中facet和group的使用
来源:互联网 发布:折800官网9.9包邮淘宝 编辑:程序博客网 时间:2024/06/06 01:32
solr中进行分组统计的应用例子(facet 和 group同时使用):
public class solr {String url = "";SolrServer server = server = new HttpSolrServer(url);SolrQuery query = new SolrQuery();query.setQuery("*:*");query.setParam(GroupParams.GROUP, true); query.setParam(GroupParams.GROUP_FIELD, "brandId"); query.set("facet", "on");query.set("facet.field","category");query.set("facet.mincount", "1");query.set("facet.limit", "15");QueryResponse response = server.query(query);FacetField categoryField = response.getFacetField("category");if (navFirstfacetField != null) {counts = categoryField.getValues();if (counts != null) {for (Count count : counts) {System.out.println("分类名称:"+count.getName()+" 分类商品数量:"+count.getCount());} }}GroupResponse groupResponse = response.getGroupResponse(); if(groupResponse != null) { List<GroupCommand> groupList = groupResponse.getValues(); for(GroupCommand groupCommand : groupList) { total = groupCommand.getMatches(); List<Group> groups = groupCommand.getValues(); for(Group group : groups) { String brandId = group.getGroupValue(); int brandNum = group.getResult().getNumFound(); String brandName = null; SolrDocumentList docList = group.getResult(); for (SolrDocument doc : docList) { brandName = StringUtil.convertStr(doc.getFieldValue("brandName")); } System.out.println("brandId:"+brandId+" brandNum:"+brandNum+" brandName:"+brandName); } } }}
0 0
- solr中facet和group的使用
- solr的group和facet
- Solr中Facet用法和Group用法
- Solr中的group与facet的区别
- Solr --- Group查询与Facet区别
- solr的facet性能
- solr的facet查询
- solr的facet查询
- solr的facet性能
- solr的facet查询
- solr的facet查询
- Solr Facet的应用
- solr的facet查询
- Solr的学习使用之(七)Solr高级查询facet、facet.pivot简介 - OnTheRoad_Lee
- Solr 使用Facet分组过程中与分词的矛盾解决办法
- solr学习第六课---solr中facet的基本应用-基于solr搜索引擎
- solr 6.3 入门(五) facet.pivot的使用
- 转:Solr学习总结-Facet(各种例子,包括facet.query的使用)
- 利用Ptrace在Android平台实现应用程序控制
- android 逆向后的smali文件中类名称的修改
- C# 温故而知新:Stream
- js中获取时间new Date()详细介绍
- Spring中的事务传播行为
- solr中facet和group的使用
- c++中Socket通信函数之select
- 花生壳远程域名打不开的分析思考及其他选择
- Visio 2007 画大括号
- java list 交集 并集 差集 去重复并集
- spring 加载xml文件或bean的方法
- 用SqlCommandBuilder 实现批量更新
- hibernate之锁表LockMode.UPGRADE
- Remote Scripting技术的实现