When I do a search with grouping result and perform group limit, I get that numFound is the same as I when I don’t use the limit.
It looks like SOLR first performs search and calculates numFound and then limit the results.
I can't use pagination and other stuff. Is there any workaround or I missed something ?
Example:
======================================
| id | publisher | book_title |
======================================
| 1 | A1 | Title Book |
| 2 | A1 | Book title 123 |
| 3 | A1 | My book |
| 4 | B2 | Hi book title |
| 5 | B2 | Another Book |
If I perform query:
q=book_title:book
&group=true
&group.field=publisher
&group.limit=1
&group.main=true
I will get numFound 5 but only 2 in the results.
"response": {
"numFound": 5,
"docs": [
{
"book_title": "My book",
"publisher": "A1"
},
{
"book_title": "Another Book",
"publisher": "B2"
}
]
}
numFound indicates the number of documents in the search index that matched your query. Solr only returns the specified number of documents in results, though. Without setting parameters, defaults are used; everything is configurable, either through the query string or in query configuration (see solrconfig. xml).
Solr has a result grouping feature. You use this feature to sort documents into groups, based on a common field value. Solr returns the top documents for each group.
Search result grouping. The Solr search result grouping feature enables grouping parent catalog entries with their underlying SKUs at query time. Products can be chosen to represent the group that is returned in search results to provide visual relevancy.
Set group.ngroups to true
.
That will produce
"grouped": {
"bl_version_id": {
"matches": 53,
"ngroups": 18,
"groups": [
{
...
I had the same problem, couldn't find a way to fix the root cause, but I will share my solution as a workaround.
What I did is
Add these faceting parameters to your query:
&facet=true
&facet.limit=-1
&facet.field=publisher
Notes:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With