Example #1
0
 /**
  * 单条数据删除
  *
  * 直接删除
  *
  * @param string $table
  * @param array $data
  */
 public function delete($table, $data)
 {
     $doc = new CloudsearchDoc($this->module, $this->ins);
     $item = array('cmd' => 'delete', 'fields' => $data);
     $r = $doc->add(array($item), $table);
     $this->checkResponse($r);
 }
 /**
  * Batch submit contents
  * @param array $contents
  */
 public function submitDocs($contents)
 {
     $doc_obj = new \CloudsearchDoc($this->options->getAppName(), $this->client);
     $docs_to_upload = array();
     foreach ($contents as $content) {
         $item = array();
         //Set operation to 'ADD'
         $item['cmd'] = 'UPDATE';
         $item["fields"] = $content;
         $docs_to_upload[] = $item;
     }
     $json = json_encode($docs_to_upload);
     //Retry service 5 times if failed
     for ($i = 1; $i < 5; $i++) {
         $pushResult = json_decode($doc_obj->add($json, "main"));
         if ($pushResult->status == "OK") {
             break;
         }
     }
 }