コード例 #1
0
 public function dropBlacklistedDocuments(array $blacklist, $metadata)
 {
     $result = $this->indexer->getDocumentUrlsInCore(['core' => $metadata->core]);
     $toDelete = [];
     foreach ($result as $document) {
         if (UrlCheck::isUrlBlacklisted($document->url, $blacklist)) {
             $toDelete[] = ['core' => $metadata->core, 'id' => $document->id, 'url' => $document->url];
         }
     }
     foreach ($toDelete as $document) {
         $this->indexer->deleteDocumentById(['core' => $document['core']], $document['id']);
         $this->logMessage("info", sprintf("Delete document %s. URL: %s", $document['id'], $document['url']), $document['url']);
     }
 }
コード例 #2
0
 /**
  * @test
  */
 public function isCorrectQueryPhraseUsedForGetDocumentsUrlsInCore()
 {
     $selectQuery = $this->getMockBuilder('Solarium\\QueryType\\Select\\Query\\Query')->setMethods(['setQuery', 'setFields'])->getMock();
     $selectQuery->expects($this->once())->method('setQuery')->with($this->equalTo('*:*'))->will($this->returnValue($selectQuery));
     $selectQuery->expects($this->once())->method('setFields')->with($this->equalTo(['url', 'id']))->will($this->returnValue($selectQuery));
     $prefetch = $this->getMockBuilder('Solarium\\Plugin\\PrefetchIterator')->getMock();
     $solrClient = $this->getMockBuilder('Solarium\\Client')->setMethods(['createSelect', 'getPlugin'])->getMock();
     $solrClient->expects($this->once())->method('createSelect')->will($this->returnValue($selectQuery));
     $solrClient->expects($this->once())->method('getPlugin')->will($this->returnValue($prefetch));
     $indexer = new Indexer($solrClient, [], 50);
     $indexer->getDocumentUrlsInCore(['core' => 'core']);
 }