Removes a single document data by ID. * * @param string $id Document ID to remove * @param string $routing Custom routing for the document * * @return array * * @throws \LogicException */ public function remove($id, $routing = null) { $params = [ 'index' => $this->getManager()->getIndexName(), 'type' => $this->type, 'id' => $id, ]; if ($routing) { $params['routing'] = $routing; } $response = $this->getManager()->getClient()->delete($params); return $response; } /** * Partial document update. * * @param string $id Document id to update. * @param array $fields Fields array to update. * @param string $script Groovy script to update fields. * @param array $params Additional parameters to pass to the client. * * @return array */ public function update($id, array $fields = [], $script = null, array $params = []) { $body = array_filter( [ 'doc' => $fields, 'script' => $script, ] ); $params = array_merge( [ 'id' => $id, 'index' => $this->getManager()->getIndexName(), 'type' => $this->type, 'body' => $body, ], $params ); return $this->getManager()->getClient()->update($params); } /** * Resolves elasticsearch type by class name. * * @param string $className * * @return array */ protected function resolveType($className) { return $this->getManager()->getMetadataCollector()->getDocumentType($className); } /** * Returns fully qualified class name. * * @return string */ public function getClassName() { return $this->className; } }