Note that custom implementations might need to be accompanied by custom mappings.
Exemplo n.º 1
0
 /**
  * Indexes several Locations
  *
  * @todo: This function and setCommit() is needed for Persistence\Solr for test speed but not part
  *       of interface for the reason described in Solr\Content\Search\Gateway\Native::bulkIndexContent
  *       Short: Bulk handling should be properly designed before added to the interface.
  *
  * @param \eZ\Publish\SPI\Persistence\Content\Location[] $locations
  */
 public function bulkIndexLocations(array $locations)
 {
     $documents = array();
     foreach ($locations as $location) {
         $documents[] = $this->mapper->mapLocation($location);
     }
     $this->gateway->bulkIndex($documents);
 }
Exemplo n.º 2
0
 /**
  * Deletes a location from the index
  *
  * @todo When we support Location-less Content, we will have to reindex instead of removing
  * @todo Should we not already support the above?
  * @todo The subtree could potentially be huge, so this implementation should scroll reindex
  *
  * @param mixed $locationId
  * @param mixed $contentId @todo Make use of this, or remove if not needed.
  */
 public function deleteLocation($locationId, $contentId)
 {
     // 1. Update (reindex) all Content in the subtree with additional Location(s) outside of it
     $ast = array("filter" => array("nested" => array("path" => "locations_doc", "filter" => array("and" => array(0 => array("regexp" => array("locations_doc.path_string_id" => ".*/{$locationId}/.*")), 1 => array("regexp" => array("locations_doc.path_string_id" => array("value" => "@&~(.*/{$locationId}/.*)", "flags" => "INTERSECTION|COMPLEMENT|ANYSTRING"))))))));
     $response = $this->gateway->findRaw(json_encode($ast), $this->documentTypeName);
     $result = json_decode($response->body);
     $documents = array();
     foreach ($result->hits->hits as $hit) {
         $documents[] = $this->mapper->mapContentById($hit->_id);
     }
     $this->gateway->bulkIndex($documents);
     // 2. Delete all Content in the subtree with no other Location(s) outside of it
     $ast["filter"]["nested"]["filter"]["and"][1] = array("not" => $ast["filter"]["nested"]["filter"]["and"][1]);
     $ast = array("query" => array("filtered" => $ast));
     $this->gateway->deleteByQuery(json_encode($ast), $this->documentTypeName);
 }
Exemplo n.º 3
0
 /**
  * Deletes a location from the index.
  *
  * @todo When we support Location-less Content, we will have to reindex instead of removing
  * @todo Should we not already support the above?
  * @todo The subtree could potentially be huge, so this implementation should scroll reindex
  *
  * @param mixed $locationId
  * @param mixed $contentId @todo Make use of this, or remove if not needed.
  */
 public function deleteLocation($locationId, $contentId)
 {
     // 1. Update (reindex) all Content in the subtree with additional Location(s) outside of it
     $ast = array('filter' => array('nested' => array('path' => 'locations_doc', 'filter' => array('and' => array(0 => array('regexp' => array('locations_doc.path_string_id' => ".*/{$locationId}/.*")), 1 => array('regexp' => array('locations_doc.path_string_id' => array('value' => "@&~(.*/{$locationId}/.*)", 'flags' => 'INTERSECTION|COMPLEMENT|ANYSTRING'))))))));
     $response = $this->gateway->findRaw(json_encode($ast), $this->documentTypeName);
     $result = json_decode($response->body);
     $documents = array();
     foreach ($result->hits->hits as $hit) {
         $documents[] = $this->mapper->mapContentById($hit->_id);
     }
     $this->gateway->bulkIndex($documents);
     // 2. Delete all Content in the subtree with no other Location(s) outside of it
     $ast['filter']['nested']['filter']['and'][1] = array('not' => $ast['filter']['nested']['filter']['and'][1]);
     $ast = array('query' => array('filtered' => $ast));
     $this->gateway->deleteByQuery(json_encode($ast), $this->documentTypeName);
 }