src/Search/Framework/Indexer.php
public function indexQueuedItem(QueueMessage $message)
    {
        $log = $this->getLogger();
        $context = array(
            'engine' => get_class($this->_searchEngine),
            'item' => $message->getBody(),
        );

        // Load the source data form the message. The message usually contains a
        // unique identifier in the body. Skip processing if false is returned
        // as the source data.
        $collection = $message->getCollection();
        $data = $collection->loadSourceData($message);

        if ($data) {
            $context['collection'] = $collection->getId();
            $log->debug('Data fetched from source', $context);

            // Build an index document from the source data.
            $document = $this->_searchEngine->newDocument($this);
            $collection->buildDocument($document, $data);
            $log->debug('Document prepared for indexing', $context);

            // Index the document, sandwich indexing with events.
            $event = new IndexDocumentEvent($this, $document, $data);
            $this->dispatchEvent(SearchEvents::DOCUMENT_PRE_INDEX, $event);
            $this->_searchEngine->indexDocument($collection, $document);
            $this->dispatchEvent(SearchEvents::DOCUMENT_POST_INDEX, $event);

            $log->debug('Document processed for indexing', $context);

        } else {
            $log->critical('Data could not be loaded from source', $context);
        }
    }
public function indexQueuedItem(QueueMessage $message)
    {
        $log = $this->getLogger();
        $context = array(
            'engine' => get_class($this->_searchEngine),
            'item' => $message->getBody(),
        );

        // Load the source data form the message. The message usually contains a
        // unique identifier in the body. Skip processing if false is returned
        // as the source data.
        $collection = $message->getCollection();
        $data = $collection->loadSourceData($message);

        if ($data) {
            $context['collection'] = $collection->getId();
            $log->debug('Data fetched from source', $context);

            // Build an index document from the source data.
            $document = $this->_searchEngine->newDocument($this);
            $collection->buildDocument($document, $data);
            $log->debug('Document prepared for indexing', $context);

            // Index the document, sandwich indexing with events.
            $event = new IndexDocumentEvent($this, $document, $data);
            $this->dispatchEvent(SearchEvents::DOCUMENT_PRE_INDEX, $event);
            $this->_searchEngine->indexDocument($collection, $document);
            $this->dispatchEvent(SearchEvents::DOCUMENT_POST_INDEX, $event);

            $log->debug('Document processed for indexing', $context);

        } else {
            $log->critical('Data could not be loaded from source', $context);
        }
    }
public function indexQueuedItem ( QueueMessage $ message ) { $ log = $ this -> getLogger ( ) ; $ context = array ( 'engine' => get_class ( $ this -> _searchEngine ) , 'item' => $ message -> getBody ( ) , ) ; // Load the source data form the message. The message usually contains a // unique identifier in the body. Skip processing if false is returned // as the source data. $ collection = $ message -> getCollection ( ) ; $ data = $ collection -> loadSourceData ( $ message ) ; if ( $ data ) { $ context [ 'collection' ] = $ collection -> getId ( ) ; $ log -> debug ( 'Data fetched from source' , $ context ) ; // Build an index document from the source data. $ document = $ this -> _searchEngine -> newDocument ( $ this ) ; $ collection -> buildDocument ( $ document , $ data ) ; $ log -> debug ( 'Document prepared for indexing' , $ context ) ; // Index the document, sandwich indexing with events. $ event = new IndexDocumentEvent ( $ this , $ document , $ data ) ; $ this -> dispatchEvent ( SearchEvents :: DOCUMENT_PRE_INDEX , $ event ) ; $ this -> _searchEngine -> indexDocument ( $ collection , $ document ) ; $ this -> dispatchEvent ( SearchEvents :: DOCUMENT_POST_INDEX , $ event ) ; $ log -> debug ( 'Document processed for indexing' , $ context ) ; } else { $ log -> critical ( 'Data could not be loaded from source' , $ context ) ; } }
Indexes an item that is queued for indexing into the search engine.
Indexes an item that is queued for indexing into the search engine .