/**
  * 获取应用的最近错误列表
  *
  * @param int $page 指定获取第几页的错误信息。默认值:1
  * @param int $pageSize 指定每页显示的错误条数。默认值:10
  *
  * @return array 返回指定页数的错误信息列表。
  */
 public function getErrorMessage($page = 1, $pageSize = 10)
 {
     $this->_checkPageClause($page);
     $this->_checkPageSizeClause($pageSize);
     $params = array('page' => $page, 'page_size' => $pageSize);
     return $this->client->call('/index/error/' . $this->indexName, $params);
 }
 /**
  * 生成HTTP的请求串,并通过CloudsearchClient类向API服务发出请求并返回结果。
  *
  * query参数中的query子句和config子句必需的,其它子句可选。
  *
  * @return string
  */
 private function call($type = 'search')
 {
     $haquery = array();
     $haquery[] = "config=" . $this->clauseConfig();
     $haquery[] = "query=" . ($this->getQuery() ? $this->getQuery() : "''") . "";
     ($f = $this->getFilter()) && ($haquery[] = 'filter=' . $f);
     ($k = $this->getPair()) && ($haquery[] = 'kvpairs=' . $k);
     if ($type == 'search') {
         ($s = $this->getSortString()) && ($haquery[] = "sort=" . $s);
         ($d = $this->getDistinctString()) && ($haquery[] = 'distinct=' . $d);
         ($a = $this->getAggregateString()) && ($haquery[] = 'aggregate=' . $a);
     }
     $params = array('query' => implode("&&", $haquery), 'index_name' => implode(";", $this->getSearchIndexes()), 'format' => $this->getFormat());
     if ($result = $this->getCustomParam()) {
         foreach ($result as $k => $v) {
             $params[$k] = $v;
         }
     }
     ($f = $this->getFetchFields()) && ($params['fetch_fields'] = implode(";", $f));
     if ($type == 'search') {
         ($f = $this->getFormulaName()) && ($params['formula_name'] = $f);
         ($f = $this->getFirstFormulaName()) && ($params['first_formula_name'] = $f);
         ($s = $this->getSummaryString()) && ($params['summary'] = $s);
         ($f = $this->getQPName()) && ($params['qp'] = implode(",", $f));
         ($f = $this->getDisabledFunctionString()) && ($params['disable'] = $f);
     } else {
         if ($type == 'scroll') {
             ($f = $this->getScroll()) && ($params['scroll'] = $f);
             ($f = $this->getScrollId()) && ($params['scroll_id'] = $f);
             $params['search_type'] = self::SEARCH_TYPE_SCAN;
         }
     }
     return $this->client->call($this->path, $params, 'GET');
 }
 /**
  * 操作docs。
  *
  * @param array|string $docs 此docs为用户push的数据,此字段为json_encode的字符串或者
  * 数据。
  * @param string $tableName 操作的表名。
  * @throws Exception
  * @return string 请求API并返回相应的结果。
  */
 private function action($docs, $tableName, $signMode = self::SIGN_MODE)
 {
     if (!is_array($docs)) {
         $docs = json_decode($docs, true);
     }
     if (!is_array($docs) || empty($docs) || !is_array($docs[0])) {
         throw new Exception('Operation failed. The docs is not correct.');
     }
     $params = array('action' => "push", 'items' => json_encode($docs), 'table_name' => $tableName);
     if ($signMode == self::SIGN_MODE) {
         $params['sign_mode'] = self::SIGN_MODE;
     }
     return $this->client->call($this->path, $params, self::METHOD);
 }
Example #4
0
 /**
  * 通过指定的天数和个数,返回top query信息。
  * @param int $num 指定返回的记录个数。
  * @param int $days 指定统计从昨天开始向前多少天的数据。
  * @return array
  */
 public function getTopQuery($num, $days)
 {
     $params = array('num' => $num, 'days' => $days);
     return $this->client->call($this->path, $params);
 }