From a95c0a5c53445fc47fa44ca8732905820f6aea74 Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Thu, 30 May 2019 19:01:58 +1200 Subject: [PATCH 1/2] DOC Suggest prefering source when using the quick set up --- docs/en/01_getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/01_getting_started.md b/docs/en/01_getting_started.md index dc6d877..9098367 100644 --- a/docs/en/01_getting_started.md +++ b/docs/en/01_getting_started.md @@ -39,7 +39,7 @@ configured and running) that each connector deals with itself, in a way best sui If you are running on a Linux-based system, you can get up and running quickly with the quickstart script, like so: ```bash -composer require silverstripe/fulltextsearch && vendor/bin/fts_quickstart +composer require silverstripe/fulltextsearch --prefer-source && vendor/bin/fts_quickstart ``` This will: From 566ffa0593d68c5f0a96db452d3a55c3382d57a7 Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Thu, 30 May 2019 19:07:20 +1200 Subject: [PATCH 2/2] NEW Disable re-indexing when migrating files --- _config/config.yml | 4 ++ .../DisableIndexingOnFileMigration.php | 37 +++++++++++++++++++ tests/DisableIndexingOnFileMigrationTest.php | 24 ++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 src/Search/Extensions/DisableIndexingOnFileMigration.php create mode 100644 tests/DisableIndexingOnFileMigrationTest.php diff --git a/_config/config.yml b/_config/config.yml index 63a8bce..1203db0 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -13,3 +13,7 @@ SilverStripe\Core\Injector\Injector: SilverStripe\FullTextSearch\Search\Queries\SearchQuery: calls: - [ setHandler, [ %$SilverStripe\FullTextSearch\Search\Adapters\SolrSearchAdapter ]] + +SilverStripe\Dev\Tasks\MigrateFileTask: + extensions: + - SilverStripe\FullTextSearch\Search\Extensions\DisableIndexingOnFileMigration diff --git a/src/Search/Extensions/DisableIndexingOnFileMigration.php b/src/Search/Extensions/DisableIndexingOnFileMigration.php new file mode 100644 index 0000000..2b7530d --- /dev/null +++ b/src/Search/Extensions/DisableIndexingOnFileMigration.php @@ -0,0 +1,37 @@ + '%$' . LoggerInterface::class . '.quiet', + ]; + + /** @var LoggerInterface */ + private $logger; + + /** + * @param LoggerInterface $logger + */ + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + } + + public function preFileMigration() + { + if (SearchUpdater::config()->get('enabled')) { + $this->logger->info('Disabling fulltext search re-indexing for this request only'); + SearchUpdater::config()->set('enabled', false); + } + } +} diff --git a/tests/DisableIndexingOnFileMigrationTest.php b/tests/DisableIndexingOnFileMigrationTest.php new file mode 100644 index 0000000..ae17e07 --- /dev/null +++ b/tests/DisableIndexingOnFileMigrationTest.php @@ -0,0 +1,24 @@ +assertTrue(SearchUpdater::config()->get('enabled')); + + Injector::inst()->get(DisableIndexingOnFileMigration::class)->preFileMigration(); + + $this->assertFalse(SearchUpdater::config()->get('enabled')); + } +}