6

http://localhost:8080/solr/select?q=(apposta apposta per) OR (sue prime ore al)&group=true&group.field=grouping_field&group.limit=5

This query returns 2 groups first group has 1 document and second group has 2 documents.

In response I see count of documents(3) but there is no counts of groups. How can I get count of groups.

javanna
  • 59,145
  • 14
  • 144
  • 125
vladimir
  • 695
  • 3
  • 10
  • 23

2 Answers2

15

Use group.ngroups=true to include the number of groups in the response.

More info @ http://wiki.apache.org/solr/FieldCollapsing

Documentation -
group.ngroups - true/false
If true, includes the number of groups that have matched the query. Default is false.

Jayendra
  • 52,349
  • 4
  • 80
  • 90
5

One comment to above answer that is 100% correct however there is extra condition!

You can not have:

group.main => 'true'

Kris79
  • 191
  • 2
  • 7
  • Any other alternative solution to get group count when using group.main=true? – Gowthaman Oct 13 '16 at 15:15
  • This is what I did to get group count but at the same time using `group.main=true`. I made 2 calls to solr. The first call will have `group.ngroups=true&rows=0`. This way we don't get any data but only the count. The second call will have `group.main=true'. Hope this helps someone. – Gowthaman Oct 13 '16 at 17:06