Client::search PHP Method

    public function search($pageSize = 10)
    {
        $criteria = new CDbCriteria();
        $criteria->compare('t.first_name', trim($this->first_name), true, 'OR');
        $criteria->compare('t.middle_name', trim($this->middle_name), true, 'OR');
        $criteria->compare('t.last_name', trim($this->last_name), true, 'OR');
        $criteria->compare('t.nick_name', trim($this->nick_name), true, 'OR');
        $criteria->compare('t.email', trim($this->email), true, 'OR');
        $criteria->compare('t.phone', trim($this->phone), true, 'OR');
        $criteria->compare('t.gender', $this->gender);
        $criteria->compare('t.status', $this->status);
        $orderTable = Order::model()->tableName();
        $orderNumberSql = "(select count(*) from {$orderTable} o where o.user_id = t.id) ";
        $orderSumSql = "(select sum(total_price) from {$orderTable} o where o.user_id = t.id AND o.paid = :paid) ";
        $criteria->compare($orderNumberSql, $this->ordersTotalNumber);
        $criteria->compare($orderSumSql, $this->ordersTotalSum);
        $criteria->select = ['*', $orderNumberSql . ' as ordersTotalNumber', $orderSumSql . ' as ordersTotalSum'];
        $criteria->params[':paid'] = Order::PAID_STATUS_PAID;
        return new CActiveDataProvider(__CLASS__, ['criteria' => $criteria, 'sort' => ['defaultOrder' => 'visit_time DESC', 'attributes' => ['ordersTotalNumber' => ['asc' => 'ordersTotalNumber ASC', 'desc' => 'ordersTotalNumber DESC'], 'ordersTotalSum' => ['asc' => 'ordersTotalSum ASC', 'desc' => 'ordersTotalSum DESC'], '*']]]);
    }

Usage Example

 /**
  * @param int $practoAccntId
  *
  * @return \ConsultBundle\Entity\DoctorEntity|null
  */
 public function retrieveDoctorProfileOld($practoAccntId = 5)
 {
     //$this->client = new Client();
     $params['index'] = $this->index;
     $params['type'] = 'search';
     $params['_source'] = array('doctor_id', 'doctor_name', 'practo_account_id', 'specialties.specialty', 'profile_picture');
     $params['body']['query']['match']['practo_account_id'] = $practoAccntId;
     $results = $this->client->search($params);
     if (count($results['hits']['hits']) === 0) {
         return null;
     }
     $doc = null;
     foreach ($results['hits']['hits'] as $result) {
         $doc = $this->populateDoctorObject($result['_source']);
     }
     if (is_null($doc)) {
         return null;
     }
     return $doc;
 }
All Usage Examples Of Client::search