ln770395339
ln770395339
采纳率100%
2017-05-15 06:26

solr 根据日期分组查询,日期字段的类型是年月日时分秒,想按照年月日分组

40
已采纳

solr 根据日期分组查询,日期字段fetchTime的类型是yyyy-mm-dd HH:mm:ss,想按照年月日分组,请问solr可以实现这种查询吗?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • ln770395339 ln770395339 4年前

    facet=on&facet.range=fetchTime&facet.range.start=2017-03-01T00:00:00Z&facet.range.end=2017-05-16T23:59:59Z&facet.range.gap=%2B1DAY&facet.date.other=all

    点赞 2 评论 复制链接分享
  • qq_18895659 AngusC· 4年前
          SolrServer server = this.getSolrServer();  
    SolrQuery param = new SolrQuery();  
    param.setQuery(QUERY_CONTENT);  
    param.setRows(QUERY_ROWS);  
    param.setParam(GroupParams.GROUP, GROUP);  
    param.setParam(GroupParams.GROUP_FIELD, GROUP_FIELD);  
    param.setParam(GroupParams.GROUP_LIMIT, GROUP_LIMIT);  
    QueryResponse response = null;  
    try {  
        response = server.query(param);  
    } catch (SolrServerException e) {  
        logger.error(e.getMessage(), e);  
    }  
    Map<String, Integer> info = new HashMap<String, Integer>();  
    GroupResponse groupResponse = response.getGroupResponse();  
    if(groupResponse != null) {  
        List<GroupCommand> groupList = groupResponse.getValues();  
        for(GroupCommand groupCommand : groupList) {  
            List<Group> groups = groupCommand.getValues();  
            for(Group group : groups) {  
                info.put(group.getGroupValue(), (int)group.getResult().getNumFound());  
            }  
        }  
    }  
    

    group可以实现分组

    点赞 1 评论 复制链接分享

相关推荐