Elastica\Index::count PHP Method

count() public method

Counts results of query.
See also: Elastica\SearchableInterface::count
public count ( string | array | Query $query = '' ) : integer
$query string | array | Query Array with all query data inside or a Elastica\Query object
return integer number of documents matching the query
    public function count($query = '')
    {
        $search = $this->createSearch($query);
        return $search->count();
    }

Usage Example

Example #1
0
 /**
  * @return int
  */
 public function getTotalCount()
 {
     try {
         return $this->index->count();
     } catch (ResponseException $e) {
         return 0;
     }
 }