eZ\Publish\Core\Search\Elasticsearch\Content\Handler::deleteContent PHP Method

deleteContent() public method

Deletes a content object from the index.
public deleteContent ( integer $contentId, integer | null $versionId = null )
$contentId integer
$versionId integer | null
    public function deleteContent($contentId, $versionId = null)
    {
        // 1. Delete the Content
        if ($versionId === null) {
            $this->gateway->deleteByQuery(json_encode(['query' => ['match' => ['_id' => $contentId]]]), $this->contentDocumentTypeIdentifier);
        } else {
            $this->gateway->delete($contentId, $this->contentDocumentTypeIdentifier);
        }
        // 2. Delete all Content's Locations
        $this->gateway->deleteByQuery(json_encode(['query' => ['match' => ['content_id_id' => $contentId]]]), $this->locationDocumentTypeIdentifier);
    }