Edwin Yeo
Edwin Yeo

Reputation: 165

Using group.ngroups during query search in Solr

I would like to check, will using the results grouping with group.ngroups (which will include the number of groups that have matched the query) in the search affects the performance of the Solr? I found that the searching speed has slowed down quite significantly after I added in the group.ngroups parameters.

I required the value of the number of groups that have matched the query. Besides this, is there other way which I can retrieve that value?

I have more than 10 million documents, with an index size of more than 500GB, and I'm using Solr 5.4.0.

Regards,
Edwin

Upvotes: 0

Views: 1544

Answers (1)

MatsLindh
MatsLindh

Reputation: 52802

Yes, it will affect performance. Everything that needs to be done to a result set (such as grouping) will affect performance in some way. How much depends on way too many factors to say exactly how much (but you've already observed that).

You can get the number of unique values (which should be the same as grouping for that field and counting the number of groups) for a field in a number of ways, which Yonik shows in his Count Distinct Values blog post.

The unique facet function is Solr’s fastest implementation to calculate the number of distinct values.

$ curl http://localhost:8983/solr/techproducts/query -d '
q=*:*&
json.facet={
  x : "unique(manu_exact)"    // manu_exact is the manufacturer indexed as a single string
}'

Upvotes: 4

Related Questions