/** * @param DocumentInterface $document the document that is providing the data for this record. * Override this method to apply custom data from a search result to a new record. */ public function parseElasticDocument(DocumentInterface $document) { $this->owner->setPrimaryKey($document->getId()); if ($document instanceof SearchResult) { $this->owner->setElasticScore($document->getScore()); } foreach ($document->getSource() as $attribute => $value) { $this->owner->{$attribute} = $value; } }
/** * Remove a document from elastic search * @param DocumentInterface $document the document to remove * @param bool $async whether or not to perform an async request * * @return \Guzzle\Http\Message\Response|mixed the response from elastic search */ public function delete(DocumentInterface $document, $async = false) { $url = $document->getIndex() . '/' . $document->getType() . '/' . $document->getId(); $client = $async ? $this->getAsyncClient() : $this->getClient(); $request = $client->delete($url); return $this->perform($request, $async); }