Spring+Cassandra+Solr Grouping

336 views Asked by At

Is it possible to grouping data more than one field by using SolrTemplate

example, i want to group by id and name in a table

1

There are 1 answers

0
Systemmanic On

As the group options returns a list of group by fields you can probably do something like this:

Query query = new SimpleQuery(new SimpleStringCriteria("*:*"));

SimpleQuery groupQuery = new SimpleQuery(new SimpleStringCriteria("*:*"));

GroupOptions groupOptions = new GroupOptions()
                .addGroupByField("id")
                .addGroupByField("name")
                .addGroupByQuery(query);

groupQuery.setGroupOptions(groupOptions);

GroupPage<Foo> page = solrTemplate.queryForGroupPage(query, Foo.class);

Read more in the docs here.