SOLR - group results using group.limit return wrong numFound

When I do a search with a grouping result and do a group constraint, I get that numFound matches I when I don't use the constraint.

It appears that SOLR first searches and computes numFound, and then restricts the results.

I cannot use pagination and other things. Is there any workaround or am I missing 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 execute the request:

 q=book_title:book &group=true &group.field=publisher &group.limit=1 &group.main=true 

I 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" } ] } 
+6
source share
5 answers

Set group.ngroups to true . It will create

 "grouped": { "bl_version_id": { "matches": 53, "ngroups": 18, "groups": [ { ... 
+4
source

I had the same problem, I could not find a way to fix the root cause, but I will share my solution as a workaround.

What i did is

  • Facet by the field in which I group.
  • Count the number of unique faces. This will match the number of unique documents (2 in your case).

Add these cut options to your request:

 &facet=true &facet.limit=-1 &facet.field=publisher 

Notes:

  • This is a bit expensive, but this is the only way that worked for me (for now).
  • This will only work if the publisher is not ambiguous
+1
source

numFound indicates the total number. of the document corresponding to the current request, here in your case 5 is correct, although you gave group.limit=1 , it will give max. 1 document per group, even if there are many documents in this group. I suggest you use group.limit=-1 in your request, it will return all 5 documents as a result.

For more information, please check the details below.

solr fieldcollapsing and maximum group.limit

http://wiki.apache.org/solr/FieldCollapsing

+1
source

group.limit is not a real limit, only NumRows is returned.

There is no easy solution to my problem in Solr.

You can find the answer here . Solr User Group

+1
source

numFound refers to the total number of documents found by solr after executing your request, which is also something you will need to do paginated based on this request.

Page splitting in solr is very similar to the way you process it using regular RDBMS, you will need to use start , and rows , for example, executing the following query, will extract 10 documents, starting from document number 20:

 ?q=you_key_word&start=20&rows=10 

This request will select for you the desired content for the landing page "this will lead to page number 3 in this case, if you have 10 documents / page", and, of course, instead of performing another request to get the total number to find out number of pages, you will have this information created for you, represented by the value "numFound".

Hope this helps

-1
source

All Articles