public function generateAndIndexSearchDocuments($resourceUri, $context, $podName, $specType = [])
    {
        $mongoCollection    = $this->config->getCollectionForCBD($this->storeName, $podName);

        $searchDocGenerator = $this->getSearchDocumentGenerator($mongoCollection, $context);
        $searchProvider = $this->getSearchProvider();

        //1. remove all search documents for this resource
        $searchProvider->deleteDocument($resourceUri, $context, $specType); // null means delete all documents for this resource

        //2. regenerate search documents for this resource
        $documentsToIndex   = [];
        // first work out what its type is
        $query = array("_id"=>array(
            'r'=>$this->labeller->uri_to_alias($resourceUri),
            'c'=>$this->getContextAlias($context)
        ));

        $resourceAndType = $mongoCollection->find(
            $query,
            [
                'projection' => ["_id" => 1, "rdf:type" => 1],
                'maxTimeMS' => $this->config->getMongoCursorTimeout()
            ]
        );
        foreach ($resourceAndType as $rt) {
            if (array_key_exists("rdf:type", $rt)) {
                $rdfTypes = [];

                if (array_key_exists('u', $rt["rdf:type"])) {
                    $rdfTypes[] = $rt["rdf:type"]['u'];
                } else {
                    // an array of types
                    foreach ($rt["rdf:type"] as $type) {
                        $rdfTypes[] = $type['u'];
                    }
                }

                $docs = $searchDocGenerator->generateSearchDocumentsBasedOnRdfTypes($rdfTypes, $resourceUri, $context);
                foreach ($docs as $d) {
                    $documentsToIndex[] = $d;
                }
            }
        }

        foreach ($documentsToIndex as $document) {
            if (!empty($document)) {
                $searchProvider->indexDocument($document);
            }
        }
    }
public function generateAndIndexSearchDocuments($resourceUri, $context, $podName, $specType = [])
    {
        $mongoCollection    = $this->config->getCollectionForCBD($this->storeName, $podName);

        $searchDocGenerator = $this->getSearchDocumentGenerator($mongoCollection, $context);
        $searchProvider = $this->getSearchProvider();

        //1. remove all search documents for this resource
        $searchProvider->deleteDocument($resourceUri, $context, $specType); // null means delete all documents for this resource

        //2. regenerate search documents for this resource
        $documentsToIndex   = [];
        // first work out what its type is
        $query = array("_id"=>array(
            'r'=>$this->labeller->uri_to_alias($resourceUri),
            'c'=>$this->getContextAlias($context)
        ));

        $resourceAndType = $mongoCollection->find(
            $query,
            [
                'projection' => ["_id" => 1, "rdf:type" => 1],
                'maxTimeMS' => $this->config->getMongoCursorTimeout()
            ]
        );
        foreach ($resourceAndType as $rt) {
            if (array_key_exists("rdf:type", $rt)) {
                $rdfTypes = [];

                if (array_key_exists('u', $rt["rdf:type"])) {
                    $rdfTypes[] = $rt["rdf:type"]['u'];
                } else {
                    // an array of types
                    foreach ($rt["rdf:type"] as $type) {
                        $rdfTypes[] = $type['u'];
                    }
                }

                $docs = $searchDocGenerator->generateSearchDocumentsBasedOnRdfTypes($rdfTypes, $resourceUri, $context);
                foreach ($docs as $d) {
                    $documentsToIndex[] = $d;
                }
            }
        }

        foreach ($documentsToIndex as $document) {
            if (!empty($document)) {
                $searchProvider->indexDocument($document);
            }
        }
    }
public function generateAndIndexSearchDocuments ( $ resourceUri , $ context , $ podName , $ specType = [ ] ) { $ mongoCollection = $ this -> config -> getCollectionForCBD ( $ this -> storeName , $ podName ) ; $ searchDocGenerator = $ this -> getSearchDocumentGenerator ( $ mongoCollection , $ context ) ; $ searchProvider = $ this -> getSearchProvider ( ) ; //1. remove all search documents for this resource $ searchProvider -> deleteDocument ( $ resourceUri , $ context , $ specType ) ; // null means delete all documents for this resource //2. regenerate search documents for this resource $ documentsToIndex = [ ] ; // first work out what its type is $ query = array ( "_id" => array ( 'r' => $ this -> labeller -> uri_to_alias ( $ resourceUri ) , 'c' => $ this -> getContextAlias ( $ context ) ) ) ; $ resourceAndType = $ mongoCollection -> find ( $ query , [ 'projection' => [ "_id" => 1 , "rdf:type" => 1 ] , 'maxTimeMS' => $ this -> config -> getMongoCursorTimeout ( ) ] ) ; foreach ( $ resourceAndType as $ rt ) { if ( array_key_exists ( "rdf:type" , $ rt ) ) { $ rdfTypes = [ ] ; if ( array_key_exists ( 'u' , $ rt [ "rdf:type" ] ) ) { $ rdfTypes [ ] = $ rt [ "rdf:type" ] [ 'u' ] ; } else { // an array of types foreach ( $ rt [ "rdf:type" ] as $ type ) { $ rdfTypes [ ] = $ type [ 'u' ] ; } } $ docs = $ searchDocGenerator -> generateSearchDocumentsBasedOnRdfTypes ( $ rdfTypes , $ resourceUri , $ context ) ; foreach ( $ docs as $ d ) { $ documentsToIndex [ ] = $ d ; } } } foreach ( $ documentsToIndex as $ document ) { if ( ! empty ( $ document ) ) { $ searchProvider -> indexDocument ( $ document ) ; } } }
Removes all existing documents for the supplied resource and regenerate the search documents
@param string $resourceUri
@param string $context
@param string $podName
@param array | string | null $specType
Removes all existing documents for the supplied resource and regenerate the search documents