solr group by查询:
1.solr wiki参考:[url]http://wiki.apache.org/solr/FieldCollapsing[/url
2.solrj group查询例子:
SolrQuery SolrQuery = new SolrQuery("*:*");
solrQuery.addFilterQuery("display:1");
solrQuery.addFilterQuery("activityBeginTime:[* TO NOW]");
solrQuery.addFilterQuery("activityEndTime:[NOW TO *]");
solrQuery.setGroup(true);
solrQuery.setParam(GroupParams.GROUP_QUERY, {"id:1","id:2"});
solrQuery.setParam(GroupParams.GROUP_LIMIT, pageSize + "");
solrQuery.setParam(GroupParams.GROUP_OFFSET, pageSize * (page - 1) + "");
solrQuery.setParam(GroupParams.GROUP_LIMIT, "1");
solrQuery.setParam(GroupParams.GROUP_SORT, "id desc", "sort asc");
solrQuery.setRows(0);
QueryResponse qr = searchSource.query(searchQuery, SolrRequest.METHOD.POST);
GroupResponse groupResponse = qr.getGroupResponse();
List<GroupCommand> list = groupResponse.getValues();
for (GroupCommand gc : list) {
List<Group> gs = gc.getValues();
if (CollectionUtils.isNotEmpty(gs)) {
for (Group g : gs) {
SolrDocumentList sds = g.getResult();
if (CollectionUtils.isNotEmpty(sds)) {
for (SolrDocument doc : sds) {
String id= doc.getFieldValue("id").toString();
}
}
}
}
}
}
分享到:
相关推荐
> 使用说明:请保留页面底部的 *powered by 28844. com* 感谢支持 在线地址: [28844.com](http://www.28844.com) | [文档地址](https://www.28844.com/) ## 技术栈 - JDK8 - Spring-Boot - MyBatis - Freemarker...
可以通过调整MapReduce任务数量、使用Local GroupBy等方法来实现。 ##### 12.5.4 数据存储优化 - 通过优化数据存储格式(如使用Parquet或ORC文件格式)、压缩算法等手段可以提高查询效率。 ##### 12.5.5 SQL优化 -...
The chapter provides step-by-step instructions for installing and configuring these components on CentOS, a popular Linux distribution. #### Chapter 3: Collecting Data with Nutch and Solr Data ...
30.5. Solr 30.5.1. Connecting to Solr 30.5.2. Spring Data Solr Repositories 30.6. Elasticsearch 30.6.1. Connecting to Elasticsearch by Using Jest 30.6.2. Connecting to Elasticsearch by Using Spring ...
8. **SQL分组查询**:`GROUP BY`语句用于将数据按一个或多个字段进行分组,以便对每个组进行聚合操作(如计数、求和等)。在分组查询中,`SELECT`后面的字段要么是分组字段,要么是聚合函数。 9. **MySQL内联查询**...