public function deleteDocument($resource, $context, $specId = array())
    {
        $query = array(_ID_KEY . '.' . _ID_RESOURCE => $this->labeller->uri_to_alias($resource),  _ID_KEY . '.' . _ID_CONTEXT => $context);
        try {
            $searchTypes = array();
            if (!empty($specId)) {
                $specTypes = $this->config->getSearchDocumentSpecifications($this->storeName, null, true);
                if(is_string($specId))
                {
                    if(!in_array($specId, $specTypes))
                    {
                        return;
                    }
                    $query[_ID_KEY][_ID_TYPE] = $specId;
                    $searchTypes[]  = $specId;
                }
                elseif(is_array($specId))
                {
                    // Only filter on search document spec types
                    $specId = array_intersect($specTypes, $specId);
                    if(empty($specId))
                    {
                        return;
                    }
                    $query[_ID_KEY . '.' . _ID_TYPE] = array('$in'=>array_values($specId));
                    $searchTypes = $specId;
                }
            }
            foreach($this->config->getCollectionsForSearch($this->storeName, $searchTypes) as $collection)
            {
                $collection->deleteMany($query);
            }
        } catch (\Exception $e) {
            throw new \Tripod\Exceptions\SearchException("Failed to Remove Document with id \n" . print_r($query, true), 0, $e);
        }
    }
public function deleteDocument($resource, $context, $specId = array())
    {
        $query = array(_ID_KEY . '.' . _ID_RESOURCE => $this->labeller->uri_to_alias($resource),  _ID_KEY . '.' . _ID_CONTEXT => $context);
        try {
            $searchTypes = array();
            if (!empty($specId)) {
                $specTypes = $this->config->getSearchDocumentSpecifications($this->storeName, null, true);
                if(is_string($specId))
                {
                    if(!in_array($specId, $specTypes))
                    {
                        return;
                    }
                    $query[_ID_KEY][_ID_TYPE] = $specId;
                    $searchTypes[]  = $specId;
                }
                elseif(is_array($specId))
                {
                    // Only filter on search document spec types
                    $specId = array_intersect($specTypes, $specId);
                    if(empty($specId))
                    {
                        return;
                    }
                    $query[_ID_KEY . '.' . _ID_TYPE] = array('$in'=>array_values($specId));
                    $searchTypes = $specId;
                }
            }
            foreach($this->config->getCollectionsForSearch($this->storeName, $searchTypes) as $collection)
            {
                $collection->deleteMany($query);
            }
        } catch (\Exception $e) {
            throw new \Tripod\Exceptions\SearchException("Failed to Remove Document with id \n" . print_r($query, true), 0, $e);
        }
    }
public function deleteDocument ( $ resource , $ context , $ specId = array ( ) ) { $ query = array ( _ID_KEY . '.' . _ID_RESOURCE => $ this -> labeller -> uri_to_alias ( $ resource ) , _ID_KEY . '.' . _ID_CONTEXT => $ context ) ; try { $ searchTypes = array ( ) ; if ( ! empty ( $ specId ) ) { $ specTypes = $ this -> config -> getSearchDocumentSpecifications ( $ this -> storeName , null , true ) ; if ( is_string ( $ specId ) ) { if ( ! in_array ( $ specId , $ specTypes ) ) { return ; } $ query [ _ID_KEY ] [ _ID_TYPE ] = $ specId ; $ searchTypes [ ] = $ specId ; } elseif ( is_array ( $ specId ) ) { // Only filter on search document spec types $ specId = array_intersect ( $ specTypes , $ specId ) ; if ( empty ( $ specId ) ) { return ; } $ query [ _ID_KEY . '.' . _ID_TYPE ] = array ( '$in' => array_values ( $ specId ) ) ; $ searchTypes = $ specId ; } } foreach ( $ this -> config -> getCollectionsForSearch ( $ this -> storeName , $ searchTypes ) as $ collection ) { $ collection -> deleteMany ( $ query ) ; } } catch ( \ Exception $ e ) { throw new \ Tripod \ Exceptions \ SearchException ( "Failed to Remove Document with id \n" . print_r ( $ query , true ) , 0 , $ e ) ; } }
Removes a single document from the search index based on the specified resource and context and spec id.
If spec id is not specified this method will delete all search documents that match the resource and context.
@param string $resource
@param string $context
@param string|array|null $specId
@throws \Tripod\Exceptions\SearchException if there was an error removing the document
@return mixed
Removes a single document from the search index based on the specified resource and context and spec id . If spec id is not specified this method will delete all search documents that match the resource and context .