public function deleteSearchDocumentsByTypeId($typeId, $timestamp = null)
    {
        $searchSpec = $this->getSearchDocumentSpecification($typeId);
        if ($searchSpec == null) {
            throw new \Tripod\Exceptions\SearchException("Could not find a search specification for $typeId");
        }
        $query = ['_id.type' => $typeId];
        if ($timestamp) {
            if (!($timestamp instanceof \MongoDB\BSON\UTCDateTime)) {
                $timestamp = new \MongoDB\BSON\UTCDateTime($timestamp);
            }
            $query['$or'] = [
                [\_CREATED_TS => ['$lt' => $timestamp]],
                [\_CREATED_TS => ['$exists' => false]]
            ];
        }
        $deleteResponse = $this->getCollectionForSearchSpec($typeId)
            ->deleteMany($query);
        return $deleteResponse->getDeletedCount();
    }
public function deleteSearchDocumentsByTypeId($typeId, $timestamp = null)
    {
        $searchSpec = $this->getSearchDocumentSpecification($typeId);
        if ($searchSpec == null) {
            throw new \Tripod\Exceptions\SearchException("Could not find a search specification for $typeId");
        }
        $query = ['_id.type' => $typeId];
        if ($timestamp) {
            if (!($timestamp instanceof \MongoDB\BSON\UTCDateTime)) {
                $timestamp = new \MongoDB\BSON\UTCDateTime($timestamp);
            }
            $query['$or'] = [
                [\_CREATED_TS => ['$lt' => $timestamp]],
                [\_CREATED_TS => ['$exists' => false]]
            ];
        }
        $deleteResponse = $this->getCollectionForSearchSpec($typeId)
            ->deleteMany($query);
        return $deleteResponse->getDeletedCount();
    }
public function deleteSearchDocumentsByTypeId ( $ typeId , $ timestamp = null ) { $ searchSpec = $ this -> getSearchDocumentSpecification ( $ typeId ) ; if ( $ searchSpec == null ) { throw new \ Tripod \ Exceptions \ SearchException ( "Could not find a search specification for $typeId" ) ; } $ query = [ '_id.type' => $ typeId ] ; if ( $ timestamp ) { if ( ! ( $ timestamp instanceof \ MongoDB \ BSON \ UTCDateTime ) ) { $ timestamp = new \ MongoDB \ BSON \ UTCDateTime ( $ timestamp ) ; } $ query [ '$or' ] = [ [ \ _CREATED_TS => [ '$lt' => $ timestamp ] ] , [ \ _CREATED_TS => [ '$exists' => false ] ] ] ; } $ deleteResponse = $ this -> getCollectionForSearchSpec ( $ typeId ) -> deleteMany ( $ query ) ; return $ deleteResponse -> getDeletedCount ( ) ; }
Removes all documents from search index based on the specified type id.
Here search type id represents to id from, mongo tripod config, that is converted to _id.type in SEARCH_INDEX_COLLECTION
If type id is not specified this method will throw an exception.
@param string                         $typeId    Search type id
@param \MongoDB\BSON\UTCDateTime|null $timestamp Optional timestamp to delete all search docs that are older than
@return integer                                  The number of search documents deleted
@throws \Tripod\Exceptions\Exception if there was an error performing the operation
Removes all documents from search index based on the specified type id . Here search type id represents to id from mongo tripod config that is converted to _id . type in SEARCH_INDEX_COLLECTION If type id is not specified this method will throw an exception .