floriansemm / SolrBundle

Solr-Integration into Symfony and Doctrine2
http://floriansemm.github.io/SolrBundle
MIT License
123 stars 73 forks source link

numberOfFoundDocuments #128

Closed IAntaresI closed 8 years ago

IAntaresI commented 8 years ago

in version 1.2 - $this->numberOfFoundDocuments = $response->getNumFound(); in FS/SolrBundle/Solr.php on line 259. In version 1.5, this is not method getNumFound () always returns 0. Or I do not understand how you can get the number of results found?

floriansemm commented 8 years ago

getNumFound is a bit deprecated

If you use query() you get an array of document which is countable, same with repository methods like findAll().

IAntaresI commented 8 years ago

The documentation is written: $ Query = $ this-> get ( 'solr.client') -> createQuery ( 'AcmeDemoBundle: Post'); $ Query-> addSearchTerm ( 'title', 'my title'); $ Query-> addSearchTerm ( 'collection_field', array ( 'value1', 'value2'));

$ Result = $ query-> getResult ();

By default, array ($ result) 10 elements that needs to be done to find out the number of found suddenly all was found 11 records or 11 million? :) If more specific I need to do pagination on the search page. Or do I need to put a large number of known $ query-> setRows (1000000); and then calculate the result?

floriansemm commented 8 years ago

$query->setRows(1000000); would be to expensive only for a calculation. I have restored the old behavior of getNumFound.

IAntaresI commented 8 years ago

Thank you very much.