/**
  * @param $locationId
  */
 protected function deleteAllItemsWithoutAdditionalLocation($locationId)
 {
     $query = $this->prepareQuery();
     $query->filter = new Criterion\LogicalAnd([$this->allItemsWithinLocation($locationId), new Criterion\LogicalNot($this->allItemsWithinLocationWithAdditionalLocation($locationId))]);
     $searchResult = $this->resultExtractor->extract($this->gateway->searchAllEndpoints($query));
     foreach ($searchResult->searchHits as $hit) {
         $idPrefix = $this->mapper->generateContentDocumentId($hit->valueObject->id);
         $this->gateway->deleteByQuery("_root_:{$idPrefix}*");
     }
 }
 /**
  * Deletes a location from the index.
  *
  * @param mixed $locationId
  * @param mixed $contentId
  */
 public function deleteLocation($locationId, $contentId)
 {
     $idPrefix = $this->mapper->generateContentDocumentId($contentId);
     $this->gateway->deleteByQuery("_root_:{$idPrefix}*");
     // TODO it seems this part of location deletion (not last location) misses integration tests
     try {
         $contentInfo = $this->contentHandler->loadContentInfo($contentId);
     } catch (NotFoundException $e) {
         return;
     }
     $content = $this->contentHandler->load($contentId, $contentInfo->currentVersionNo);
     $this->bulkIndexContent(array($content));
 }