private List searchCategoryList(Map searchMap) {
SimpleQuery query = new SimpleQuery(new Criteria("hyd_keywords").is(searchMap.get("keywords"))); //相当where
query.setGroupOptions(new GroupOptions().addGroupByField("hyd_category")); //相当group by
GroupPage<TbItem> page = solrTemplate.queryForGroupPage(query, TbItem.class);
//根据 列 所得
GroupResult<TbItem> groupResult = page.getGroupResult("hyd_category"); //相当于 select xxx,yyy
Page<GroupEntry<TbItem>> groupEntries = groupResult.getGroupEntries(); //Page接口 继承 Iterable<T> 本人理解:GroupResult<TbItem> 无法直接转List 方便操作,需走这一步过渡
//分组入口 List
List<GroupEntry<TbItem>> content = groupEntries.getContent();
List<String> list = new ArrayList<>();
for (GroupEntry<TbItem> groupEntry : content) {
list.add(groupEntry.getGroupValue());
}
return list;
}
sql方式去理解
hyd_keywords 复制域 (hyd_title hyd_category hyd_seller hyd_brand)