/** * Perform the delete operation * * @throws exceptions\RuntimeException * @return \Sherlock\responses\DeleteResponse */ public function execute() { //if this is an internal Sherlock BatchCommand, make sure index/types/action are filled if ($this->batch instanceof BatchCommand) { $this->batch->fillIndex($this->params['index'][0])->fillType($this->params['type'][0]); } return parent::execute(); }
/** * Execute the search request on the ES cluster * * @throws \Sherlock\common\exceptions\RuntimeException * @return \Sherlock\responses\QueryResponse */ public function execute() { $id = $this->params['id']; if (isset($this->params['index'])) { $index = implode(',', $this->params['index']); } else { $index = ''; } if (isset($this->params['type'])) { $type = implode(',', $this->params['type']); } else { $type = ''; } if (isset($queryParams)) { $queryParams = '?' . implode("&", $queryParams); } else { $queryParams = ''; } $command = new \Sherlock\requests\Command(); $command->index($index)->type($type)->id($id . $queryParams)->action('get'); $this->batch->clearCommands(); $this->batch->addCommand($command); $ret = parent::execute(); return $ret[0]; }
/** * Perform the indexing operation * * @throws exceptions\RuntimeException * @return \Sherlock\responses\IndexResponse */ public function execute() { /* foreach (array('index', 'type') as $key) { if (!isset($this->params[$key])) { throw new exceptions\RuntimeException($key." cannot be empty."); } } foreach (array('index', 'type') as $key) { if (count($this->params[$key]) > 1) { throw new exceptions\RuntimeException("Only one ".$key." may be inserted into at a time."); } } */ $this->finalizeCurrentCommand(); //if this is an internal Sherlock BatchCommand, make sure index/types/action are filled if ($this->batch instanceof BatchCommand) { if (isset($this->params['index'][0])) { $this->batch->fillIndex($this->params['index'][0]); } if (isset($this->params['type'][0])) { $this->batch->fillType($this->params['type'][0]); } } return parent::execute(); }
/** * Execute the RawRequest * * @throws \Sherlock\common\exceptions\RuntimeException * @return \Sherlock\responses\QueryResponse */ public function execute() { if (!isset($this->params['uri'])) { throw new exceptions\RuntimeException("URI is required for RawRequest"); } if (!isset($this->params['method'])) { throw new exceptions\RuntimeException("Method is required for RawRequest"); } $command = new Command(); $command->index($this->params['uri'])->action($this->params['method']); if (isset($this->params['body'])) { $command->data($this->params['body']); } $this->batch->clearCommands(); $this->batch->addCommand($command); $ret = parent::execute(); return $ret[0]; }
/** * Update/add the Mapping of an index * * @return \Sherlock\responses\IndexResponse * @throws exceptions\RuntimeException */ public function updateMapping() { if (!isset($this->params['index'])) { throw new exceptions\RuntimeException("Index cannot be empty."); } if (count($this->params['indexMappings']) > 1) { throw new exceptions\RuntimeException("May only update one mapping at a time."); } if (!isset($this->params['type'])) { throw new exceptions\RuntimeException("Type must be specified."); } if (count($this->params['type']) > 1) { throw new exceptions\RuntimeException("Only one type may be updated at a time."); } $index = implode(',', $this->params['index']); $body = $this->params['indexMappings']; $command = new Command(); $command->index($index)->type($this->params['type'][0])->id('_mapping')->action('put')->data(json_encode($body, JSON_FORCE_OBJECT)); $this->batch->clearCommands(); $this->batch->addCommand($command); $ret = parent::execute(); //clear out mappings, settings //$this->resetIndex(); return $ret[0]; }
/** * Execute the search request on the ES cluster * * @throws \Sherlock\common\exceptions\RuntimeException * @return \Sherlock\responses\QueryResponse */ public function execute() { $finalQuery = $this->composeFinalQuery(); if (isset($this->params['index'])) { $index = implode(',', $this->params['index']); } else { $index = ''; } if (isset($this->params['type'])) { $type = implode(',', $this->params['type']); } else { $type = ''; } if (isset($this->params['search_type'])) { $queryParams[] = $this->params['search_type']; } if (isset($this->params['routing'])) { $queryParams[] = $this->params['routing']; } if (isset($queryParams)) { $queryParams = '?' . implode("&", $queryParams); } else { $queryParams = ''; } $command = new Command(); $command->index($index)->type($type)->id('_search' . $queryParams)->action('post')->data($finalQuery); $this->batch->clearCommands(); $this->batch->addCommand($command); $ret = parent::execute(); return $ret[0]; }