Why Solr match data and count mismatch while using group.limit?

392 views Asked by At

I am executing a SOLR Query where I group titles and limit the number of title in groups. The problem I face is I don't get an exact number of matches with the passed limit.

e.g:

http://localhost:8080/solr/select?wt=json&indent=true&fl=publication,book_code,bookID,book_date,book_images&q=asset_type:Book+AND+AND+engineering:true&group=true&group.field=book_code&group.limit=3&rows=50000&group.sort=book_date+desc

How do I convert this query so that I can fetch 10000 records at a time.

Currently the returned result:

{"responseHeader"=>
  {"status"=>0,
   "QTime"=>195,
   "params"=>
    {"fl"=>"publication,book_code,BookID,book_date,book_images",
     "indent"=>"true",
     "q"=>"doc_type:Book AND engineering:true",
     "group.limit"=>"3",
     "group.field"=>"book_code",
     "group.sort"=>"book_date desc",
     "group"=>"true",
     "wt"=>"json",
     "rows"=>"50000"}},
 "grouped"=>
  {"book_code"=>
    {"matches"=>30216,
    "groups"=>
      [{"groupValue"=>"NYM",
        "doclist"=>
         {"numFound"=>2683,
          "start"=>0,
          "docs"=>
           [{"book_code"=>"NYM", .... } and so on 

When I try to retrieve the count of the grouped books I get :

result["grouped"]["book_code"]["groups"].count #=> 276

Which does not match with the returned matches result.

1

There are 1 answers

2
MatsLindh On BEST ANSWER

matches is the total number of documents that matched your query. The ["groups"].count value is the number of distinct groups returned. I.e. the 30216 documents returned belongs to 276 different groups.