mirror of
https://github.com/Codappix/search_core.git
synced 2024-12-25 14:16:10 +01:00
BUGFIX: Remove records during update if no longer available
E.g. update is to deactivate a record. In this case we will not be able to update the record but should delete him instead.
This commit is contained in:
parent
ea8eb8148e
commit
0815eaff6b
2 changed files with 33 additions and 1 deletions
|
@ -99,7 +99,8 @@ abstract class AbstractIndexer implements IndexerInterface
|
|||
|
||||
$this->connection->addDocument($this->getDocumentName(), $record);
|
||||
} catch (NoRecordFoundException $e) {
|
||||
$this->logger->info('Could not index document.', [$e->getMessage()]);
|
||||
$this->logger->info('Could not index document. Try to delete it therefore.', [$e->getMessage()]);
|
||||
$this->connection->deleteDocument($this->getDocumentName(), $identifier);
|
||||
}
|
||||
$this->logger->info('Finish indexing');
|
||||
}
|
||||
|
|
|
@ -205,4 +205,35 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
|
|||
'Record was indexed with resolved category relation, but should not have any.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function indexingDeltedRecordIfRecordShouldBeIndexedButIsNoLongerAvailableAndWasAlreadyIndexed()
|
||||
{
|
||||
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
|
||||
->get(IndexerFactory::class)
|
||||
->getIndexer('tt_content')
|
||||
->indexAllDocuments()
|
||||
;
|
||||
|
||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||
$this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 documents were indexed.');
|
||||
|
||||
$this->getConnectionPool()->getConnectionForTable('tt_content')
|
||||
->update(
|
||||
'tt_content',
|
||||
['hidden' => true],
|
||||
['uid' => 10]
|
||||
);
|
||||
|
||||
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
|
||||
->get(IndexerFactory::class)
|
||||
->getIndexer('tt_content')
|
||||
->indexDocument(10)
|
||||
;
|
||||
|
||||
$response = $this->client->request('typo3content/_search?q=*:*');
|
||||
$this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document is in index.');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue