Commit 8bcc392b authored by Markus Kalkbrenner's avatar Markus Kalkbrenner Committed by GitHub

Increase compatibility between stream and search result (#583)

Increase compatibility between stream rsults ans serach result
parent fa383609
......@@ -64,6 +64,7 @@ class ResponseParser extends ResponseParserAbstract implements ResponseParserInt
return $this->addHeaderInfo(
$data,
[
'numfound' => count($documents),
'documents' => $documents,
]
);
......
......@@ -10,6 +10,15 @@ use Solarium\QueryType\Select\Result\DocumentInterface;
*/
class Result extends BaseResult implements \IteratorAggregate, \Countable
{
/**
* Solr numFound.
*
* This is NOT the number of document fetched from Solr!
*
* @var int
*/
protected $numfound;
/**
* Document instances array.
*
......@@ -48,6 +57,36 @@ class Result extends BaseResult implements \IteratorAggregate, \Countable
return $this->status;
}
/**
* Get Solr query time.
*
* This doesn't include things like the HTTP responsetime. Purely the Solr
* query execution time.
*
* @return int
*/
public function getQueryTime()
{
$this->parseResponse();
return $this->queryTime;
}
/**
* get Solr numFound.
*
* Returns the total number of documents found by Solr (this is NOT the
* number of document fetched from Solr!)
*
* @return int
*/
public function getNumFound()
{
$this->parseResponse();
return $this->numfound;
}
/**
* Get Solr status code.
*
......@@ -104,6 +143,18 @@ class Result extends BaseResult implements \IteratorAggregate, \Countable
return $this->response->getBody();
}
/**
* Get Solr response body in JSON format.
*
* More expressive convenience method that just call getBody().
*
* @return string JSON
*/
public function getJson()
{
return $this->getBody();
}
/**
* Get Solr response data.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment