solrTemplate.saveBean(new ExampleSolrBean("id_3", "name2", "category2", 1, true));
solrTemplate.saveBean(new ExampleSolrBean("id_4", "name3", "category2"));
solrTemplate.commit();
Function f = IfFunction.when("inStock").then("1").otherwise("2");
Query q1 = new SimpleQuery("cat:category2");
Query q2 = new SimpleQuery("cat:category1");
SimpleQuery groupQuery = new SimpleQuery(new SimpleStringCriteria("*:*"));
GroupOptions groupOptions = new GroupOptions();
groupQuery.setGroupOptions(groupOptions);
groupOptions.addSort(new Sort("name", "id"));
groupOptions.addGroupByField("name");
groupOptions.addGroupByFunction(f);
groupOptions.addGroupByQuery(q1);
groupOptions.addGroupByQuery(q2);