diff --git a/Resources/Public/Icons/PluginResults.svg b/Resources/Public/Icons/PluginSearch.svg
similarity index 100%
rename from Resources/Public/Icons/PluginResults.svg
rename to Resources/Public/Icons/PluginSearch.svg
diff --git a/ext_localconf.php b/ext_localconf.php
index afc2a451..8452ac8a 100644
--- a/ext_localconf.php
+++ b/ext_localconf.php
@@ -12,9 +12,9 @@
['source' => 'EXT:search_core/Resources/Public/Icons/PluginForm.svg']
);
$iconRegistry->registerIcon(
- 'plugin-' . $extension . '-results',
+ 'plugin-' . $extension . '-search',
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
- ['source' => 'EXT:search_core/Resources/Public/Icons/PluginResults.svg']
+ ['source' => 'EXT:search_core/Resources/Public/Icons/PluginSearch.svg']
);
// TODO: Add hook for Extbase -> to handle records modified through
@@ -45,18 +45,10 @@
TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Codappix.' . $extension,
- 'Results',
- ['Search' => 'results'],
+ 'Search',
['Search' => 'results']
);
- TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
- 'Codappix.' . $extension,
- 'Form',
- ['Search' => 'form'],
- ['Search' => 'form']
- );
-
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
''
);
@@ -65,10 +57,10 @@
(isset($configuration['disable.']['elasticsearch']) &&
filter_var($configuration['disable.']['elasticsearch'], FILTER_VALIDATE_BOOLEAN) === false)
) {
- \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)
- ->registerImplementation(
- \Codappix\SearchCore\Connection\ConnectionInterface::class,
- \Codappix\SearchCore\Connection\Elasticsearch::class
- );
+ $container = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class);
+ $container->registerImplementation(
+ \Codappix\SearchCore\Connection\ConnectionInterface::class,
+ \Codappix\SearchCore\Connection\Elasticsearch::class
+ );
}
}, $_EXTKEY, $_EXTCONF);
From ef43bc167421f7e694822cdd512c7c70a6e763a0 Mon Sep 17 00:00:00 2001
From: Benjamin Serfhos
Date: Mon, 29 Oct 2018 17:22:41 +0100
Subject: [PATCH 42/73] [FEATURE] Use interface for SearchService
Added cached proxy service for data interaction
---
Classes/Controller/SearchController.php | 26 ++++---------
Classes/Domain/Search/CachedSearchService.php | 7 +++-
Classes/Domain/Search/SearchService.php | 2 +-
.../Domain/Search/SearchServiceInterface.php | 39 +++++++++++++++++++
ext_localconf.php | 4 ++
5 files changed, 58 insertions(+), 20 deletions(-)
create mode 100644 Classes/Domain/Search/SearchServiceInterface.php
diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php
index 3f125046..8ef0f0cd 100644
--- a/Classes/Controller/SearchController.php
+++ b/Classes/Controller/SearchController.php
@@ -22,7 +22,7 @@
*/
use Codappix\SearchCore\Domain\Model\SearchRequest;
-use Codappix\SearchCore\Domain\Search\CachedSearchService;
+use Codappix\SearchCore\Domain\Search\SearchServiceInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
@@ -31,21 +31,24 @@
class SearchController extends ActionController
{
/**
- * @var CachedSearchService
+ * @var SearchServiceInterface
*/
protected $searchService;
/**
- * @param CachedSearchService $searchService
+ * @param SearchServiceInterface $searchService
*/
- public function __construct(CachedSearchService $searchService)
+ public function __construct(SearchServiceInterface $searchService)
{
$this->searchService = $searchService;
parent::__construct();
}
- public function initializeSearchAction()
+ /**
+ * Allow dynamic properties in search request
+ */
+ public function initializeResultsAction()
{
if (isset($this->settings['searching']['mode'])
&& $this->settings['searching']['mode'] === 'filter'
@@ -63,23 +66,10 @@ public function initializeSearchAction()
}
}
- /**
- * Display results and deliver original request and result to view.
- */
- public function formAction(SearchRequest $searchRequest = null)
- {
- $this->action($searchRequest);
- }
-
/**
* Display results and deliver original request and result to view.
*/
public function resultsAction(SearchRequest $searchRequest = null)
- {
- $this->action($searchRequest);
- }
-
- private function action(SearchRequest $searchRequest = null)
{
$searchResult = null;
if ($searchRequest !== null) {
diff --git a/Classes/Domain/Search/CachedSearchService.php b/Classes/Domain/Search/CachedSearchService.php
index 48a16140..db94c841 100644
--- a/Classes/Domain/Search/CachedSearchService.php
+++ b/Classes/Domain/Search/CachedSearchService.php
@@ -29,7 +29,7 @@
* Service: Cached Search
* @package Codappix\SearchCore\Domain\Search
*/
-class CachedSearchService implements SingletonInterface
+class CachedSearchService implements SingletonInterface, SearchServiceInterface
{
/**
* @var array
@@ -55,6 +55,11 @@ public function search(SearchRequestInterface $searchRequest): SearchResultInter
return $this->results[$hash] = $this->searchService->search($searchRequest);
}
+ public function processResult(SearchResultInterface $searchResult): SearchResultInterface
+ {
+ return $this->searchService->processResult($searchResult);
+ }
+
protected function getHash(SearchRequestInterface $searchRequest): string
{
if (is_callable([$searchRequest, 'getRequestHash'])) {
diff --git a/Classes/Domain/Search/SearchService.php b/Classes/Domain/Search/SearchService.php
index 01c6f1b6..fedf09e9 100644
--- a/Classes/Domain/Search/SearchService.php
+++ b/Classes/Domain/Search/SearchService.php
@@ -35,7 +35,7 @@
/**
* Service to process a search request.
*/
-class SearchService
+class SearchService implements SearchServiceInterface
{
/**
* @var ConnectionInterface
diff --git a/Classes/Domain/Search/SearchServiceInterface.php b/Classes/Domain/Search/SearchServiceInterface.php
new file mode 100644
index 00000000..fafb06b4
--- /dev/null
+++ b/Classes/Domain/Search/SearchServiceInterface.php
@@ -0,0 +1,39 @@
+
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+use Codappix\SearchCore\Connection\SearchRequestInterface;
+use Codappix\SearchCore\Connection\SearchResultInterface;
+
+/**
+ * Service to process a search request.
+ */
+interface SearchServiceInterface
+{
+
+ public function search(SearchRequestInterface $searchRequest): SearchResultInterface;
+
+ /**
+ * Processes the result, e.g. applies configured data processing to result.
+ */
+ public function processResult(SearchResultInterface $searchResult): SearchResultInterface;
+}
diff --git a/ext_localconf.php b/ext_localconf.php
index 8452ac8a..ef4accda 100644
--- a/ext_localconf.php
+++ b/ext_localconf.php
@@ -62,5 +62,9 @@
\Codappix\SearchCore\Connection\ConnectionInterface::class,
\Codappix\SearchCore\Connection\Elasticsearch::class
);
+ $container->registerImplementation(
+ \Codappix\SearchCore\Domain\Search\SearchServiceInterface::class,
+ \Codappix\SearchCore\Domain\Search\CachedSearchService::class
+ );
}
}, $_EXTKEY, $_EXTCONF);
From 615d24b126e9624d467b09d1ca3f972fc691090f Mon Sep 17 00:00:00 2001
From: Benjamin Serfhos
Date: Tue, 30 Oct 2018 09:18:29 +0100
Subject: [PATCH 43/73] [TASK] Update unit tests for renaming controller
initialize
---
Tests/Unit/Controller/SearchControllerTest.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Tests/Unit/Controller/SearchControllerTest.php b/Tests/Unit/Controller/SearchControllerTest.php
index 0357b868..ba1d2af7 100644
--- a/Tests/Unit/Controller/SearchControllerTest.php
+++ b/Tests/Unit/Controller/SearchControllerTest.php
@@ -76,7 +76,7 @@ public function searchRequestArgumentIsAddedIfModeIsFilterAndArgumentDoesNotExis
]
]);
- $this->subject->initializeSearchAction();
+ $this->subject->initializeResultsAction();
$this->assertInstanceOf(
SearchRequest::class,
$this->request->getArgument('searchRequest'),
@@ -100,7 +100,7 @@ public function searchRequestArgumentIsAddedToExistingArguments()
]
]);
- $this->subject->initializeSearchAction();
+ $this->subject->initializeResultsAction();
$this->assertInstanceOf(
SearchRequest::class,
$this->request->getArgument('searchRequest'),
@@ -120,7 +120,7 @@ public function searchRequestArgumentIsNotAddedIfModeIsNotFilter()
{
$this->inject($this->subject, 'settings', ['searching' => []]);
- $this->subject->initializeSearchAction();
+ $this->subject->initializeResultsAction();
$this->assertFalse(
$this->request->hasArgument('searchRequest'),
'Search request should not exist.'
From 3a2c700ff1a7ff43cca8e7d6c9b5f210cd0168c0 Mon Sep 17 00:00:00 2001
From: Benjamin Serfhos
Date: Tue, 30 Oct 2018 09:19:05 +0100
Subject: [PATCH 44/73] [TASK] Remove unused constant
---
Configuration/TypoScript/constants.typoscript | 1 -
1 file changed, 1 deletion(-)
diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript
index c6b22c6f..7ff92dbc 100644
--- a/Configuration/TypoScript/constants.typoscript
+++ b/Configuration/TypoScript/constants.typoscript
@@ -6,7 +6,6 @@ plugin.tx_searchcore {
}
settings {
- searchOverview =
connections {
elasticsearch {
host = localhost
From ee1f235c2e63778ec37a2fd45f6ac31298aef886 Mon Sep 17 00:00:00 2001
From: Benjamin Serfhos
Date: Tue, 30 Oct 2018 09:50:26 +0100
Subject: [PATCH 45/73] [TASK] Use filter interface for custom added filter
---
.../Filter/FrontendUserAccessFilter.php | 22 ++---
.../Filter/InvalidSearchFilterException.php | 26 ++++++
.../Search/Filter/SearchFilterInterface.php | 33 +++++++
Classes/Domain/Search/QueryFactory.php | 87 +++++++++++--------
Configuration/TypoScript/setup.typoscript | 4 +-
.../20181028-user-access-indexed.rst | 6 +-
.../20181030-custom-class-filter.rst | 29 +++++++
7 files changed, 154 insertions(+), 53 deletions(-)
rename Classes/{Hook => Domain/Search}/Filter/FrontendUserAccessFilter.php (78%)
create mode 100644 Classes/Domain/Search/Filter/InvalidSearchFilterException.php
create mode 100644 Classes/Domain/Search/Filter/SearchFilterInterface.php
create mode 100644 Documentation/source/changelog/20181030-custom-class-filter.rst
diff --git a/Classes/Hook/Filter/FrontendUserAccessFilter.php b/Classes/Domain/Search/Filter/FrontendUserAccessFilter.php
similarity index 78%
rename from Classes/Hook/Filter/FrontendUserAccessFilter.php
rename to Classes/Domain/Search/Filter/FrontendUserAccessFilter.php
index e96276f4..42f9d2c3 100644
--- a/Classes/Hook/Filter/FrontendUserAccessFilter.php
+++ b/Classes/Domain/Search/Filter/FrontendUserAccessFilter.php
@@ -1,6 +1,6 @@
@@ -25,26 +25,28 @@
/**
* Filter: FrontendUserAccess
- * @package Codappix\SearchCore\Hook\Filter
*/
-class FrontendUserAccessFilter
+class FrontendUserAccessFilter implements SearchFilterInterface
{
- /**
- * @param array $parameters
- * @return void
- */
- public function generate($parameters)
+ public function add(array $query, array $config, $value): array
{
- $this->appendQueryWithAccessFilter($parameters['query'], $parameters['value']);
+ return $this->addAccessFilter($query, $value);
}
- protected function appendQueryWithAccessFilter(array &$query, string $field)
+ /**
+ * Add simple boolean lookup for filtering on access groups
+ */
+ protected function addAccessFilter(array $query, string $field): array
{
$query['query']['bool']['must'][] = [
'terms' => [$field => $this->getUserGroups()]
];
+ return $query;
}
+ /**
+ * Get inherited user groups from logged in user or simulated user
+ */
protected function getUserGroups(): array
{
$feUser = $this->getFrontendUserAuthentication();
diff --git a/Classes/Domain/Search/Filter/InvalidSearchFilterException.php b/Classes/Domain/Search/Filter/InvalidSearchFilterException.php
new file mode 100644
index 00000000..7199c58f
--- /dev/null
+++ b/Classes/Domain/Search/Filter/InvalidSearchFilterException.php
@@ -0,0 +1,26 @@
+
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+class InvalidSearchFilterException extends \InvalidArgumentException
+{
+}
diff --git a/Classes/Domain/Search/Filter/SearchFilterInterface.php b/Classes/Domain/Search/Filter/SearchFilterInterface.php
new file mode 100644
index 00000000..fa781d6e
--- /dev/null
+++ b/Classes/Domain/Search/Filter/SearchFilterInterface.php
@@ -0,0 +1,33 @@
+
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+interface SearchFilterInterface
+{
+ /**
+ * @param array $query
+ * @param array $config
+ * @param mixed $value
+ * @return array Adjusted $query
+ */
+ public function add(array $query, array $config, $value): array;
+}
diff --git a/Classes/Domain/Search/QueryFactory.php b/Classes/Domain/Search/QueryFactory.php
index 66eaf16b..0c0969fa 100644
--- a/Classes/Domain/Search/QueryFactory.php
+++ b/Classes/Domain/Search/QueryFactory.php
@@ -25,8 +25,12 @@
use Codappix\SearchCore\Configuration\ConfigurationUtility;
use Codappix\SearchCore\Configuration\InvalidArgumentException;
use Codappix\SearchCore\Connection\SearchRequestInterface;
+use Codappix\SearchCore\Domain\Search\Filter\InvalidSearchFilterException;
+use Codappix\SearchCore\Domain\Search\Filter\SearchFilterInterface;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
+use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
class QueryFactory
{
@@ -45,14 +49,21 @@ class QueryFactory
*/
protected $configurationUtility;
+ /**
+ * @var ObjectManagerInterface
+ */
+ protected $objectManager;
+
public function __construct(
\TYPO3\CMS\Core\Log\LogManager $logManager,
ConfigurationContainerInterface $configuration,
- ConfigurationUtility $configurationUtility
+ ConfigurationUtility $configurationUtility,
+ ObjectManagerInterface $objectManager
) {
$this->logger = $logManager->getLogger(__CLASS__);
$this->configuration = $configuration;
$this->configurationUtility = $configurationUtility;
+ $this->objectManager = $objectManager;
}
/**
@@ -231,50 +242,50 @@ protected function addFilters(SearchRequestInterface $searchRequest, array &$que
protected function addFilter(string $name, $value, array $config, array &$query): array
{
- if (!empty($config)) {
- if ($config['type'] && $config['type'] === 'user') {
- if (!isset($config['userFunc'])) {
- throw new MissingAttributeException('No userFunc configured for filter type: user', 1539876182018);
- }
-
- $parameters = [
- 'config' => $config,
- 'value' => $value,
- 'query' => &$query,
- ];
- GeneralUtility::callUserFunction($config['userFunc'], $parameters, $this);
- } else {
- $filter = [];
- if (isset($config['fields'])) {
- foreach ($config['fields'] as $elasticField => $inputField) {
- $filter[$elasticField] = $value[$inputField];
- }
- }
-
- if (isset($config['raw'])) {
- $filter = array_merge($config['raw'], $filter);
- }
-
- if ($config['type'] === 'range') {
- $query['query']['bool']['filter'][] = [
- 'range' => [
- $config['field'] => $filter
- ]
- ];
- } else {
- $query['query']['bool']['filter'][] = [
- $config['field'] => $filter
- ];
- }
- }
- } else {
+ if (empty($config)) {
+ // Fallback on default term query when no added configuration
$query['query']['bool']['filter'][] = [
'term' => [
$name => $value
]
];
+ return $query;
}
+ if ($config['custom'] && $config['type'] === 'custom') {
+ $customFilter = $this->objectManager->get($config['custom']);
+ if (!($customFilter instanceof SearchFilterInterface)) {
+ throw new InvalidSearchFilterException(
+ 'Custom filter (' . $config['custom'] . ') not instance of SearchFilterInterface',
+ 1539876182018
+ );
+ }
+
+ return $customFilter->add($query, $config, $value);
+ }
+
+ $filter = [];
+ if (isset($config['fields'])) {
+ foreach ($config['fields'] as $elasticField => $inputField) {
+ $filter[$elasticField] = $value[$inputField];
+ }
+ }
+
+ if (isset($config['raw'])) {
+ $filter = array_merge($config['raw'], $filter);
+ }
+
+ if ($config['type'] === 'range') {
+ $query['query']['bool']['filter'][] = [
+ 'range' => [
+ $config['field'] => $filter
+ ]
+ ];
+ } else {
+ $query['query']['bool']['filter'][] = [
+ $config['field'] => $filter
+ ];
+ }
return $query;
}
diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript
index 981d0336..671a071c 100644
--- a/Configuration/TypoScript/setup.typoscript
+++ b/Configuration/TypoScript/setup.typoscript
@@ -47,8 +47,8 @@ plugin.tx_searchcore {
mapping {
filter {
frontendUserAccess {
- type = user
- userFunc = Codappix\SearchCore\Hook\Filter\FrontendUserAccessFilter->generate
+ type = custom
+ custom = Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter
}
}
}
diff --git a/Documentation/source/changelog/20181028-user-access-indexed.rst b/Documentation/source/changelog/20181028-user-access-indexed.rst
index 966dacb0..2456e1ae 100644
--- a/Documentation/source/changelog/20181028-user-access-indexed.rst
+++ b/Documentation/source/changelog/20181028-user-access-indexed.rst
@@ -1,5 +1,5 @@
Feature "Added frontend user authentication access"
-===============================================================
+===================================================
Indexation added based on page access via ``fe_group`` and inherited
from ```extendToSubpages```.
@@ -7,8 +7,8 @@ from ```extendToSubpages```.
The searching is added via typoscript using the UserFunc filter::
frontendUserAccess {
- type = user
- userFunc = Codappix\SearchCore\Hook\Filter\FrontendUserAccessFilter->generate
+ type = custom
+ custom = Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter
}
To bypass this filter simply unset default filter in searching.filter
diff --git a/Documentation/source/changelog/20181030-custom-class-filter.rst b/Documentation/source/changelog/20181030-custom-class-filter.rst
new file mode 100644
index 00000000..07a305db
--- /dev/null
+++ b/Documentation/source/changelog/20181030-custom-class-filter.rst
@@ -0,0 +1,29 @@
+Feature "Manipulate search filter"
+==================================
+
+You can manipulate the filter via a custom class through the ``custom`` type typoscript
+mapping.::
+
+ plugin.tx_searchcore.settings.searching {
+ mapping {
+ filter {
+ frontendUserAccess {
+ type = custom
+ custom = Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter
+ }
+ }
+ }
+ }
+
+If you want to force this filter on searching make sure to define them as default filters like:::
+
+ plugin.tx_searchcore.settings.searching {
+ filter {
+ frontendUserAccess = search_access
+ }
+ }
+
+Example
+-------
+See ``Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter`` as example.
+
From b63168b8b71d28409cb6f9fc2ec6e6f7b5611091 Mon Sep 17 00:00:00 2001
From: Benjamin Serfhos
Date: Tue, 30 Oct 2018 09:59:20 +0100
Subject: [PATCH 46/73] [TASK] Remove unneeded pluginNamespace
---
Configuration/TypoScript/setup.typoscript | 3 ---
1 file changed, 3 deletions(-)
diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript
index 671a071c..f3429aea 100644
--- a/Configuration/TypoScript/setup.typoscript
+++ b/Configuration/TypoScript/setup.typoscript
@@ -1,8 +1,5 @@
plugin.tx_searchcore {
view {
- # This sets the plugin namespace of all your plugins inside the extension to "tx_searchcore",
- # making it possible to directly access search_core parameters in your controller:
- pluginNamespace = tx_searchcore
templateRootPaths.10 = {$plugin.tx_searchcore.view.templateRootPath}
partialRootPaths.10 = {$plugin.tx_searchcore.view.partialRootPath}
layoutRootPaths.10 = {$plugin.tx_searchcore.view.layoutRootPath}
From 2e327db47c24bc2b3a56c73cbb1f7ccd8c50130d Mon Sep 17 00:00:00 2001
From: Benjamin Serfhos
Date: Tue, 30 Oct 2018 10:03:10 +0100
Subject: [PATCH 47/73] [TASK] Finetune QueryFactoryTest based on changes
---
Tests/Unit/Domain/Search/QueryFactoryTest.php | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/Tests/Unit/Domain/Search/QueryFactoryTest.php b/Tests/Unit/Domain/Search/QueryFactoryTest.php
index 45b77a99..6b11d1a9 100644
--- a/Tests/Unit/Domain/Search/QueryFactoryTest.php
+++ b/Tests/Unit/Domain/Search/QueryFactoryTest.php
@@ -28,6 +28,7 @@
use Codappix\SearchCore\Domain\Model\SearchRequest;
use Codappix\SearchCore\Domain\Search\QueryFactory;
use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase;
+use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
class QueryFactoryTest extends AbstractUnitTestCase
{
@@ -41,13 +42,21 @@ class QueryFactoryTest extends AbstractUnitTestCase
*/
protected $configuration;
+ /**
+ * @var ObjectManagerInterface
+ */
+ protected $objectManager;
+
public function setUp()
{
parent::setUp();
$this->configuration = $this->getMockBuilder(ConfigurationContainerInterface::class)->getMock();
$configurationUtility = new ConfigurationUtility();
- $this->subject = new QueryFactory($this->getMockedLogger(), $this->configuration, $configurationUtility);
+ $this->objectManager = $this->getMockBuilder(ObjectManagerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->subject = new QueryFactory($this->getMockedLogger(), $this->configuration, $configurationUtility, $this->objectManager);
}
/**
From 4f7ccef2f6335b84dd9ac894e2f8752078532aa8 Mon Sep 17 00:00:00 2001
From: Benjamin Serfhos
Date: Tue, 30 Oct 2018 13:33:14 +0100
Subject: [PATCH 48/73] [TASK] Apply CGL changes
---
Tests/Unit/Command/IndexCommandControllerTest.php | 5 ++++-
Tests/Unit/Domain/Search/QueryFactoryTest.php | 7 ++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Tests/Unit/Command/IndexCommandControllerTest.php b/Tests/Unit/Command/IndexCommandControllerTest.php
index e3c1e77d..7a18f055 100644
--- a/Tests/Unit/Command/IndexCommandControllerTest.php
+++ b/Tests/Unit/Command/IndexCommandControllerTest.php
@@ -234,7 +234,10 @@ public function indexerSkipsAndOutputsNonExistingIdentifier()
$this->indexerFactory->expects($this->exactly(2))
->method('getIndexer')
->withConsecutive(['nonExisting'], ['allowedTable'])
- ->will($this->onConsecutiveCalls($this->throwException(new NoMatchingIndexerException), $this->returnValue($indexerMock)));
+ ->will($this->onConsecutiveCalls(
+ $this->throwException(new NoMatchingIndexerException),
+ $this->returnValue($indexerMock)
+ ));
$this->subject->indexCommand('nonExisting, allowedTable');
}
diff --git a/Tests/Unit/Domain/Search/QueryFactoryTest.php b/Tests/Unit/Domain/Search/QueryFactoryTest.php
index 6b11d1a9..e647003c 100644
--- a/Tests/Unit/Domain/Search/QueryFactoryTest.php
+++ b/Tests/Unit/Domain/Search/QueryFactoryTest.php
@@ -56,7 +56,12 @@ public function setUp()
$this->objectManager = $this->getMockBuilder(ObjectManagerInterface::class)
->disableOriginalConstructor()
->getMock();
- $this->subject = new QueryFactory($this->getMockedLogger(), $this->configuration, $configurationUtility, $this->objectManager);
+ $this->subject = new QueryFactory(
+ $this->getMockedLogger(),
+ $this->configuration,
+ $configurationUtility,
+ $this->objectManager
+ );
}
/**
From 4da6e2fec703ca5ebe6ccaec78d7f461d0bbcdf7 Mon Sep 17 00:00:00 2001
From: Benjamin Serfhos
Date: Wed, 31 Oct 2018 09:40:33 +0100
Subject: [PATCH 49/73] [TASK] Add a little description howto extend
configuration
---
Documentation/source/development/configuration.rst | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/source/development/configuration.rst b/Documentation/source/development/configuration.rst
index fc061ba8..ba976c70 100644
--- a/Documentation/source/development/configuration.rst
+++ b/Documentation/source/development/configuration.rst
@@ -3,6 +3,12 @@
Using custom (non-typoscript) configuration
===========================================
+When you are in need of your own non-typoscript configuration, you can create your own
+Configuration Container using the TYPO3 Dependency Injection handler.
+
+Example: Configuration through LocalConfiguration.php
+-----------------------------------------------------
+
Configure your custom ext_localconf.php::
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)
From 8531f26410baa75558e776d6b0fbc91dd0316fb6 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Thu, 27 Dec 2018 11:56:02 +0100
Subject: [PATCH 50/73] BUGFIX: Keep default action non cacheable
Otherwise user input is saved and re displayed to foreign visitors.
If someone is in need for an cached version, he can create a plugin
inside his sitepackage with a different plugin signature but same
action.
If that does not work, we might add another action for caching.
Also keep old action name to be non breaking.
---
Classes/Controller/SearchController.php | 4 ++--
ext_localconf.php | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php
index 8ef0f0cd..1cdd7992 100644
--- a/Classes/Controller/SearchController.php
+++ b/Classes/Controller/SearchController.php
@@ -48,7 +48,7 @@ public function __construct(SearchServiceInterface $searchService)
/**
* Allow dynamic properties in search request
*/
- public function initializeResultsAction()
+ public function initializeSearchAction()
{
if (isset($this->settings['searching']['mode'])
&& $this->settings['searching']['mode'] === 'filter'
@@ -69,7 +69,7 @@ public function initializeResultsAction()
/**
* Display results and deliver original request and result to view.
*/
- public function resultsAction(SearchRequest $searchRequest = null)
+ public function searchAction(SearchRequest $searchRequest = null)
{
$searchResult = null;
if ($searchRequest !== null) {
diff --git a/ext_localconf.php b/ext_localconf.php
index ef4accda..419495e4 100644
--- a/ext_localconf.php
+++ b/ext_localconf.php
@@ -46,7 +46,8 @@
TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Codappix.' . $extension,
'Search',
- ['Search' => 'results']
+ ['Search' => 'search'],
+ ['Search' => 'search']
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
From 6f34ca273b04a7a87168a47369a889dfacf7fbb8 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Thu, 27 Dec 2018 11:57:58 +0100
Subject: [PATCH 51/73] BUGFIX: Keep necessary type hint for extbase
---
Classes/Domain/Model/SearchRequest.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Classes/Domain/Model/SearchRequest.php b/Classes/Domain/Model/SearchRequest.php
index 17911f6f..fa05904b 100644
--- a/Classes/Domain/Model/SearchRequest.php
+++ b/Classes/Domain/Model/SearchRequest.php
@@ -91,6 +91,11 @@ public function getSearchTerm(): string
return $this->query;
}
+ /**
+ * Type hint necessary for extbase!
+ *
+ * @param array $filter
+ */
public function setFilter(array $filter)
{
$filter = ArrayUtility::removeArrayEntryByValue($filter, '');
From 9c2db0b5ba36544e0319228a3ce2a6db69441a28 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 17:59:23 +0100
Subject: [PATCH 52/73] TASK: Remove custom filter for fe group filtering
As this didn't work on first use. Also no tests are available for this
feature yet.
As we remove the whole feature in a single commit, we can revert this
commit later. This way we can upgrade Elasticsearch and provide this
feature later on.
---
.../Domain/Index/TcaIndexer/PagesIndexer.php | 38 ----------
.../Index/TcaIndexer/TcaTableService.php | 13 ----
.../Filter/FrontendUserAccessFilter.php | 74 -------------------
.../Filter/InvalidSearchFilterException.php | 26 -------
.../Search/Filter/SearchFilterInterface.php | 33 ---------
Classes/Domain/Search/QueryFactory.php | 14 ----
Configuration/TypoScript/setup.typoscript | 13 ----
.../20181028-user-access-indexed.rst | 14 ----
.../20181030-custom-class-filter.rst | 29 --------
9 files changed, 254 deletions(-)
delete mode 100644 Classes/Domain/Search/Filter/FrontendUserAccessFilter.php
delete mode 100644 Classes/Domain/Search/Filter/InvalidSearchFilterException.php
delete mode 100644 Classes/Domain/Search/Filter/SearchFilterInterface.php
delete mode 100644 Documentation/source/changelog/20181028-user-access-indexed.rst
delete mode 100644 Documentation/source/changelog/20181030-custom-class-filter.rst
diff --git a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
index 1718cb85..5c1bca47 100644
--- a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
+++ b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
@@ -66,9 +66,6 @@ protected function prepareRecord(array &$record)
{
parent::prepareRecord($record);
- // Override access from parent rootline
- $record['search_access'] = $this->fetchAccess($record['uid'], (array)$record['search_access']);
-
$possibleTitleFields = ['nav_title', 'tx_tqseo_pagetitle_rel', 'title'];
foreach ($possibleTitleFields as $searchTitleField) {
if (isset($record[$searchTitleField]) && trim($record[$searchTitleField])) {
@@ -140,41 +137,6 @@ protected function fetchMediaForPage(int $uid): array
return $this->fetchSysFileReferenceUids($uid, 'pages', 'media');
}
- protected function fetchAccess(int $uid, array $pageAccess): array
- {
- try {
- $rootline = $this->objectManager->get(RootlineUtility::class, $uid)->get();
- } catch (\RuntimeException $e) {
- $this->logger->notice(
- sprintf('Could not fetch rootline for page %u, because: %s', $uid, $e->getMessage()),
- [$pageAccess, $e]
- );
- return $pageAccess;
- }
-
- $access = [$pageAccess];
- $extended = false;
- foreach ($rootline as $pageInRootLine) {
- if ($pageInRootLine['extendToSubpages'] && (!empty($pageInRootLine['fe_group']))) {
- $extended = true;
- $access[] = GeneralUtility::intExplode(
- ',',
- $pageInRootLine['fe_group'],
- true
- );
- }
- }
-
- // Return combined rootline extended access and return unique id's
- $access = array_unique(array_merge(...$access));
-
- // Remove public value if fe_group is extended to this page
- if ($extended && ($key = array_search(0, $access, true)) !== false) {
- unset($access[$key]);
- }
- return array_values($access);
- }
-
protected function fetchSysFileReferenceUids(int $uid, string $tablename, string $fieldname): array
{
$imageRelationUids = [];
diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService.php b/Classes/Domain/Index/TcaIndexer/TcaTableService.php
index ab5c70c9..8e5cde9c 100644
--- a/Classes/Domain/Index/TcaIndexer/TcaTableService.php
+++ b/Classes/Domain/Index/TcaIndexer/TcaTableService.php
@@ -146,19 +146,6 @@ public function prepareRecord(array &$record)
if (isset($record[$this->tca['ctrl']['label']]) && !isset($record['search_title'])) {
$record['search_title'] = $record[$this->tca['ctrl']['label']];
}
-
- if (isset(
- $this->tca['ctrl']['enablecolumns']['fe_group'],
- $record[$this->tca['ctrl']['enablecolumns']['fe_group']]
- )) {
- $groups = GeneralUtility::intExplode(
- ',',
- $record[$this->tca['ctrl']['enablecolumns']['fe_group']],
- true
- );
- // Always fallback on public visibility when configured
- $record['search_access'] = !empty($groups) ? $groups : [0];
- }
}
protected function getWhereClause(): Where
diff --git a/Classes/Domain/Search/Filter/FrontendUserAccessFilter.php b/Classes/Domain/Search/Filter/FrontendUserAccessFilter.php
deleted file mode 100644
index 42f9d2c3..00000000
--- a/Classes/Domain/Search/Filter/FrontendUserAccessFilter.php
+++ /dev/null
@@ -1,74 +0,0 @@
-
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
-
-/**
- * Filter: FrontendUserAccess
- */
-class FrontendUserAccessFilter implements SearchFilterInterface
-{
- public function add(array $query, array $config, $value): array
- {
- return $this->addAccessFilter($query, $value);
- }
-
- /**
- * Add simple boolean lookup for filtering on access groups
- */
- protected function addAccessFilter(array $query, string $field): array
- {
- $query['query']['bool']['must'][] = [
- 'terms' => [$field => $this->getUserGroups()]
- ];
- return $query;
- }
-
- /**
- * Get inherited user groups from logged in user or simulated user
- */
- protected function getUserGroups(): array
- {
- $feUser = $this->getFrontendUserAuthentication();
- if ($feUser !== null) {
- // If groups is not yet rendered, make sure the group data are fetched
- if (!isset($feUser->groupData['uid'])) {
- $feUser->fetchGroupData();
- }
-
- $values = $feUser->groupData['uid'];
- if (!empty($values)) {
- // Add public content with values
- return array_merge([0], $values);
- }
- }
-
- // Fallback on public content
- return [0];
- }
-
- protected function getFrontendUserAuthentication(): FrontendUserAuthentication
- {
- return $GLOBALS['TSFE']->fe_user ?? null;
- }
-}
diff --git a/Classes/Domain/Search/Filter/InvalidSearchFilterException.php b/Classes/Domain/Search/Filter/InvalidSearchFilterException.php
deleted file mode 100644
index 7199c58f..00000000
--- a/Classes/Domain/Search/Filter/InvalidSearchFilterException.php
+++ /dev/null
@@ -1,26 +0,0 @@
-
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-class InvalidSearchFilterException extends \InvalidArgumentException
-{
-}
diff --git a/Classes/Domain/Search/Filter/SearchFilterInterface.php b/Classes/Domain/Search/Filter/SearchFilterInterface.php
deleted file mode 100644
index fa781d6e..00000000
--- a/Classes/Domain/Search/Filter/SearchFilterInterface.php
+++ /dev/null
@@ -1,33 +0,0 @@
-
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-interface SearchFilterInterface
-{
- /**
- * @param array $query
- * @param array $config
- * @param mixed $value
- * @return array Adjusted $query
- */
- public function add(array $query, array $config, $value): array;
-}
diff --git a/Classes/Domain/Search/QueryFactory.php b/Classes/Domain/Search/QueryFactory.php
index 0c0969fa..f34befc9 100644
--- a/Classes/Domain/Search/QueryFactory.php
+++ b/Classes/Domain/Search/QueryFactory.php
@@ -25,8 +25,6 @@
use Codappix\SearchCore\Configuration\ConfigurationUtility;
use Codappix\SearchCore\Configuration\InvalidArgumentException;
use Codappix\SearchCore\Connection\SearchRequestInterface;
-use Codappix\SearchCore\Domain\Search\Filter\InvalidSearchFilterException;
-use Codappix\SearchCore\Domain\Search\Filter\SearchFilterInterface;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
@@ -252,18 +250,6 @@ protected function addFilter(string $name, $value, array $config, array &$query)
return $query;
}
- if ($config['custom'] && $config['type'] === 'custom') {
- $customFilter = $this->objectManager->get($config['custom']);
- if (!($customFilter instanceof SearchFilterInterface)) {
- throw new InvalidSearchFilterException(
- 'Custom filter (' . $config['custom'] . ') not instance of SearchFilterInterface',
- 1539876182018
- );
- }
-
- return $customFilter->add($query, $config, $value);
- }
-
$filter = [];
if (isset($config['fields'])) {
foreach ($config['fields'] as $elasticField => $inputField) {
diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript
index f3429aea..7ff8d295 100644
--- a/Configuration/TypoScript/setup.typoscript
+++ b/Configuration/TypoScript/setup.typoscript
@@ -36,19 +36,6 @@ plugin.tx_searchcore {
# Default query fields (leave empty for all)
query =
}
-
- filter {
- frontendUserAccess = search_access
- }
-
- mapping {
- filter {
- frontendUserAccess {
- type = custom
- custom = Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter
- }
- }
- }
}
}
}
diff --git a/Documentation/source/changelog/20181028-user-access-indexed.rst b/Documentation/source/changelog/20181028-user-access-indexed.rst
deleted file mode 100644
index 2456e1ae..00000000
--- a/Documentation/source/changelog/20181028-user-access-indexed.rst
+++ /dev/null
@@ -1,14 +0,0 @@
-Feature "Added frontend user authentication access"
-===================================================
-
-Indexation added based on page access via ``fe_group`` and inherited
-from ```extendToSubpages```.
-
-The searching is added via typoscript using the UserFunc filter::
-
- frontendUserAccess {
- type = custom
- custom = Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter
- }
-
-To bypass this filter simply unset default filter in searching.filter
diff --git a/Documentation/source/changelog/20181030-custom-class-filter.rst b/Documentation/source/changelog/20181030-custom-class-filter.rst
deleted file mode 100644
index 07a305db..00000000
--- a/Documentation/source/changelog/20181030-custom-class-filter.rst
+++ /dev/null
@@ -1,29 +0,0 @@
-Feature "Manipulate search filter"
-==================================
-
-You can manipulate the filter via a custom class through the ``custom`` type typoscript
-mapping.::
-
- plugin.tx_searchcore.settings.searching {
- mapping {
- filter {
- frontendUserAccess {
- type = custom
- custom = Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter
- }
- }
- }
- }
-
-If you want to force this filter on searching make sure to define them as default filters like:::
-
- plugin.tx_searchcore.settings.searching {
- filter {
- frontendUserAccess = search_access
- }
- }
-
-Example
--------
-See ``Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter`` as example.
-
From 18cb95b8e95a7e778fdca0571f23fe413a3ebe28 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 18:01:25 +0100
Subject: [PATCH 53/73] TASK: Update elasticsearch even further
Use latest stable 6.x releases, for elasticsearch and used library.
---
.travis.yml | 2 +-
composer.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index d4f07e29..28afd5ea 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ addons:
packages:
- oracle-java8-set-default
before_install:
- - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.1.deb && sudo dpkg -i --force-confnew elasticsearch-6.4.1.deb && sudo service elasticsearch restart
+ - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.deb && sudo dpkg -i --force-confnew elasticsearch-6.5.4.deb && sudo service elasticsearch restart
- mysql -u root -e 'GRANT ALL ON `typo3_ci_ft%`.* TO travis@127.0.0.1;'
language: php
diff --git a/composer.json b/composer.json
index 07a679f5..3ad4242b 100644
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,7 @@
"require": {
"php": ">=7.0.0",
"typo3/cms": ">= 8.7.0 < 9.0.0",
- "ruflin/elastica": "^6.0.2"
+ "ruflin/elastica": "^6.1.0"
},
"require-dev": {
"phpunit/phpunit": "~6.4.4",
From ea8b4f45386235e1ad3141078c113e90b0d910cb Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 18:03:14 +0100
Subject: [PATCH 54/73] TASK: Fix / improve some comments
* Add missing throws annotation.
* Remove useless comments.
* Import namespaces used in comments.
---
Classes/Configuration/ConfigurationContainer.php | 4 +++-
Classes/Connection/Elasticsearch/DocumentFactory.php | 4 ----
Classes/Connection/Elasticsearch/SearchResult.php | 2 ++
Classes/Domain/Search/SearchServiceInterface.php | 4 +++-
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php
index a491c308..b213c9ba 100644
--- a/Classes/Configuration/ConfigurationContainer.php
+++ b/Classes/Configuration/ConfigurationContainer.php
@@ -26,7 +26,7 @@
/**
* Container of all configurations for extension.
- * Always inject this to have a single place for configuration and parsing only once.
+ * Always inject this to have a single place for configuration.
*/
class ConfigurationContainer implements ConfigurationContainerInterface
{
@@ -39,6 +39,8 @@ class ConfigurationContainer implements ConfigurationContainerInterface
/**
* Inject settings via ConfigurationManager.
+ *
+ * @throws NoConfigurationException
*/
public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
{
diff --git a/Classes/Connection/Elasticsearch/DocumentFactory.php b/Classes/Connection/Elasticsearch/DocumentFactory.php
index d5707892..9b8fcf0c 100644
--- a/Classes/Connection/Elasticsearch/DocumentFactory.php
+++ b/Classes/Connection/Elasticsearch/DocumentFactory.php
@@ -44,8 +44,6 @@ public function injectLogger(\TYPO3\CMS\Core\Log\LogManager $logManager)
}
/**
- * Creates document from document.
- *
* @throws \InvalidArgumentException If no search identifier was provided.
*/
public function getDocument(string $documentType, array $document): \Elastica\Document
@@ -67,8 +65,6 @@ public function getDocument(string $documentType, array $document): \Elastica\Do
}
/**
- * Creates documents based on documents.
- *
* @throws \InvalidArgumentException If no search identifier was provided.
*/
public function getDocuments(string $documentType, array $documents): array
diff --git a/Classes/Connection/Elasticsearch/SearchResult.php b/Classes/Connection/Elasticsearch/SearchResult.php
index 1704f2d7..f178c681 100644
--- a/Classes/Connection/Elasticsearch/SearchResult.php
+++ b/Classes/Connection/Elasticsearch/SearchResult.php
@@ -21,6 +21,8 @@
* 02110-1301, USA.
*/
+use Codappix\SearchCore\Connection\FacetInterface;
+use Codappix\SearchCore\Connection\ResultItemInterface;
use Codappix\SearchCore\Connection\SearchRequestInterface;
use Codappix\SearchCore\Connection\SearchResultInterface;
use Codappix\SearchCore\Domain\Model\QueryResultInterfaceStub;
diff --git a/Classes/Domain/Search/SearchServiceInterface.php b/Classes/Domain/Search/SearchServiceInterface.php
index fafb06b4..977a6f60 100644
--- a/Classes/Domain/Search/SearchServiceInterface.php
+++ b/Classes/Domain/Search/SearchServiceInterface.php
@@ -29,7 +29,9 @@
*/
interface SearchServiceInterface
{
-
+ /**
+ * Fetches result for provided search request.
+ */
public function search(SearchRequestInterface $searchRequest): SearchResultInterface;
/**
From 13cd87019f443051c65d046394c5d5aa1ba12bef Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 18:05:24 +0100
Subject: [PATCH 55/73] TASK: Refactor type handling for elasticsearch
With V6 of elasticsearch the meaning / handling of index and type has
changed, and it will change further in the future.
We therefore move code to own classes and adjust / refactor calling
code.
---
Classes/Connection/Elasticsearch.php | 48 ++++++++-----------
.../Elasticsearch/MappingFactory.php | 20 ++++++--
.../Connection/Elasticsearch/TypeFactory.php | 24 +++++++++-
.../Elasticsearch/MappingFactoryTest.php | 43 +++++++++++------
4 files changed, 84 insertions(+), 51 deletions(-)
diff --git a/Classes/Connection/Elasticsearch.php b/Classes/Connection/Elasticsearch.php
index c7e85041..8d6f2325 100644
--- a/Classes/Connection/Elasticsearch.php
+++ b/Classes/Connection/Elasticsearch.php
@@ -24,6 +24,7 @@
use Codappix\SearchCore\Connection\Elasticsearch\SearchResult;
use Codappix\SearchCore\Domain\Search\QueryFactory;
use Elastica\Query;
+use Elastica\Type;
use TYPO3\CMS\Core\SingletonInterface as Singleton;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
@@ -118,7 +119,7 @@ public function addDocument(string $documentType, array $document)
{
$this->withType(
$documentType,
- function ($type) use ($documentType, $document) {
+ function (Type $type, string $documentType) use ($document) {
$type->addDocument($this->documentFactory->getDocument($documentType, $document));
}
);
@@ -129,7 +130,7 @@ public function deleteDocument(string $documentType, string $identifier)
try {
$this->withType(
$documentType,
- function ($type) use ($identifier) {
+ function (Type $type, string $documentType) use ($identifier) {
$type->deleteById($identifier);
}
);
@@ -145,7 +146,7 @@ public function updateDocument(string $documentType, array $document)
{
$this->withType(
$documentType,
- function ($type) use ($documentType, $document) {
+ function (Type $type, string $documentType) use ($document) {
$type->updateDocument($this->documentFactory->getDocument($documentType, $document));
}
);
@@ -155,7 +156,7 @@ public function addDocuments(string $documentType, array $documents)
{
$this->withType(
$documentType,
- function ($type) use ($documentType, $documents) {
+ function (Type $type, string $documentType) use ($documents) {
$type->addDocuments($this->documentFactory->getDocuments($documentType, $documents));
}
);
@@ -205,23 +206,6 @@ public function deleteIndexByQuery(Query $query)
}
}
- /**
- * Execute given callback with Elastica Type based on provided documentType
- */
- protected function withType(string $documentType, callable $callback)
- {
- $type = $this->getType($documentType);
- // TODO: Check whether it's to heavy to send it so often e.g. for every single document.
- // Perhaps add command controller to submit mapping?!
- // Also it's not possible to change mapping without deleting index first.
- // Mattes told about a solution.
- // So command looks like the best way so far, except we manage mattes solution.
- // Still then this should be done once. So perhaps singleton which tracks state and does only once?
- $this->mappingFactory->getMapping($type, $documentType)->send();
- $callback($type);
- $type->getIndex()->refresh();
- }
-
public function search(SearchRequestInterface $searchRequest): SearchResultInterface
{
$this->logger->debug('Search for', [$searchRequest->getSearchTerm()]);
@@ -233,14 +217,20 @@ public function search(SearchRequestInterface $searchRequest): SearchResultInter
return $this->objectManager->get(SearchResult::class, $searchRequest, $search->search());
}
- protected function getType($documentType): \Elastica\Type
+ /**
+ * Execute given callback with Elastica Type based on provided documentType
+ */
+ private function withType(string $documentType, callable $callback)
{
- return $this->typeFactory->getType(
- $this->indexFactory->getIndex(
- $this->connection,
- $documentType
- ),
- 'document'
- );
+ $type = $this->typeFactory->getType($documentType);
+ // TODO: Check whether it's to heavy to send it so often e.g. for every single document.
+ // Perhaps add command controller to submit mapping?!
+ // Also it's not possible to change mapping without deleting index first.
+ // Mattes told about a solution.
+ // So command looks like the best way so far, except we manage mattes solution.
+ // Still then this should be done once. So perhaps singleton which tracks state and does only once?
+ $this->mappingFactory->getMapping($documentType)->send();
+ $callback($type, $documentType);
+ $type->getIndex()->refresh();
}
}
diff --git a/Classes/Connection/Elasticsearch/MappingFactory.php b/Classes/Connection/Elasticsearch/MappingFactory.php
index 8076593f..a1edcff4 100644
--- a/Classes/Connection/Elasticsearch/MappingFactory.php
+++ b/Classes/Connection/Elasticsearch/MappingFactory.php
@@ -35,29 +35,39 @@ class MappingFactory implements Singleton
*/
protected $configuration;
+ /**
+ * @var TypeFactory
+ */
+ protected $typeFactory;
+
/**
* @param ConfigurationContainerInterface $configuration
*/
- public function __construct(ConfigurationContainerInterface $configuration)
- {
+ public function __construct(
+ ConfigurationContainerInterface $configuration,
+ TypeFactory $typeFactory
+ ) {
$this->configuration = $configuration;
+ $this->typeFactory = $typeFactory;
}
/**
* Get an mapping based on type.
*/
- public function getMapping(\Elastica\Type $type, string $documentType = null): \Elastica\Type\Mapping
+ public function getMapping(string $documentType): \Elastica\Type\Mapping
{
+ $type = $this->typeFactory->getType($documentType);
+
$mapping = new \Elastica\Type\Mapping();
$mapping->setType($type);
- $configuration = $this->getConfiguration($documentType ?? $type->getName());
+ $configuration = $this->getConfiguration($documentType);
$mapping->setProperties($configuration);
return $mapping;
}
- protected function getConfiguration(string $identifier): array
+ private function getConfiguration(string $identifier): array
{
try {
return $this->configuration->get('indexing.' . $identifier . '.mapping');
diff --git a/Classes/Connection/Elasticsearch/TypeFactory.php b/Classes/Connection/Elasticsearch/TypeFactory.php
index d14fb681..92cc6a1e 100644
--- a/Classes/Connection/Elasticsearch/TypeFactory.php
+++ b/Classes/Connection/Elasticsearch/TypeFactory.php
@@ -21,6 +21,7 @@
* 02110-1301, USA.
*/
+use Codappix\SearchCore\Connection\Elasticsearch\IndexFactory;
use TYPO3\CMS\Core\SingletonInterface as Singleton;
/**
@@ -30,11 +31,30 @@
*/
class TypeFactory implements Singleton
{
+ /**
+ * @var IndexFactory
+ */
+ protected $indexFactory;
+
+ /**
+ * @var Connection
+ */
+ private $connection;
+
+ public function __construct(
+ Connection $connection,
+ IndexFactory $indexFactory
+ ) {
+ $this->indexFactory = $indexFactory;
+ $this->connection = $connection;
+ }
+
/**
* Get an index bases on TYPO3 table name.
*/
- public function getType(\Elastica\Index $index, string $documentType): \Elastica\Type
+ public function getType(string $documentType): \Elastica\Type
{
- return $index->getType($documentType);
+ $index = $this->indexFactory->getIndex($this->connection, $documentType);
+ return $index->getType('document');
}
}
diff --git a/Tests/Unit/Connection/Elasticsearch/MappingFactoryTest.php b/Tests/Unit/Connection/Elasticsearch/MappingFactoryTest.php
index 2be69a92..d2c89c98 100644
--- a/Tests/Unit/Connection/Elasticsearch/MappingFactoryTest.php
+++ b/Tests/Unit/Connection/Elasticsearch/MappingFactoryTest.php
@@ -23,7 +23,9 @@
use Codappix\SearchCore\Configuration\ConfigurationContainerInterface;
use Codappix\SearchCore\Connection\Elasticsearch\MappingFactory;
+use Codappix\SearchCore\Connection\Elasticsearch\TypeFactory;
use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase;
+use Elastica\Type;
class MappingFactoryTest extends AbstractUnitTestCase
{
@@ -32,12 +34,24 @@ class MappingFactoryTest extends AbstractUnitTestCase
*/
protected $subject;
+ /**
+ * @var ConfigurationContainerInterface
+ */
+ protected $configurationMock;
+
+ /**
+ * @var TypeFactory
+ */
+ protected $typeFactoryMock;
+
public function setUp()
{
parent::setUp();
- $this->configuration = $this->getMockBuilder(ConfigurationContainerInterface::class)->getMock();
- $this->subject = new MappingFactory($this->configuration);
+ $this->configurationMock = $this->getMockBuilder(ConfigurationContainerInterface::class)->getMock();
+ $this->typeFactoryMock = $this->getMockBuilder(TypeFactory::class)->disableOriginalConstructor()->getMock();
+
+ $this->subject = new MappingFactory($this->configurationMock, $this->typeFactoryMock);
}
/**
@@ -45,28 +59,27 @@ public function setUp()
*/
public function typoScriptConfigurationIsProvidedToIndex()
{
- $indexName = 'someIndex';
+ $documentType = 'someDocument';
$configuration = [
'channel' => [
'type' => 'keyword',
],
];
- $type = $this->getMockBuilder(\Elastica\Type::class)
- ->disableOriginalConstructor()
- ->getMock();
- $type->expects($this->any())
- ->method('getName')
- ->willReturn($indexName);
- $this->configuration->expects($this->once())
+
+ $typeMock = $this->getMockBuilder(Type::class)->disableOriginalConstructor()->getMock();
+
+ $this->typeFactoryMock->expects($this->any())
+ ->method('getType')
+ ->with($documentType)
+ ->willReturn($typeMock);
+ $this->configurationMock->expects($this->once())
->method('get')
- ->with('indexing.' . $indexName . '.mapping')
+ ->with('indexing.' . $documentType . '.mapping')
->willReturn($configuration);
- $mapping = $this->subject->getMapping($type)->toArray()[$indexName];
+ $mapping = $this->subject->getMapping($documentType)->toArray()[''];
$this->assertArraySubset(
- [
- 'channel' => $configuration['channel']
- ],
+ $configuration,
$mapping['properties'],
true,
'Configuration for properties was not set for mapping.'
From a858d748eec66300c0489db6917f51ef405520be Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 18:06:26 +0100
Subject: [PATCH 56/73] TASK: Shorten code
* Do not use variable, instead provide result to method call.
* Do not provide public method which is not part of API. Otherwise one
might use it in custom PHP code and switch connection later on. Then the
method call will no longer work.
---
Classes/Connection/Elasticsearch.php | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/Classes/Connection/Elasticsearch.php b/Classes/Connection/Elasticsearch.php
index 8d6f2325..81e12584 100644
--- a/Classes/Connection/Elasticsearch.php
+++ b/Classes/Connection/Elasticsearch.php
@@ -179,17 +179,16 @@ public function deleteIndex()
public function deleteIndexByDocumentType(string $documentType)
{
- $query = Query::create([
+ $this->deleteIndexByQuery(Query::create([
'query' => [
'term' => [
- 'search_document_type' => $documentType
- ]
- ]
- ]);
- $this->deleteIndexByQuery($query);
+ 'search_document_type' => $documentType,
+ ],
+ ],
+ ]));
}
- public function deleteIndexByQuery(Query $query)
+ private function deleteIndexByQuery(Query $query)
{
$index = $this->connection->getClient()->getIndex($this->indexFactory->getIndexName());
if (!$index->exists()) {
From 564ca1511c1b8dcacc20b7fae7eb4ef9dc7c7fe5 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 18:07:25 +0100
Subject: [PATCH 57/73] TASK: Refactor code into common flow
As we have the same flow in some more places, we refactor this part to
follow this conventions.
---
.../Connection/Elasticsearch/SearchResult.php | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/Classes/Connection/Elasticsearch/SearchResult.php b/Classes/Connection/Elasticsearch/SearchResult.php
index f178c681..cd3db0a1 100644
--- a/Classes/Connection/Elasticsearch/SearchResult.php
+++ b/Classes/Connection/Elasticsearch/SearchResult.php
@@ -121,14 +121,17 @@ protected function initFacets()
}
$this->facets = [];
- if ($this->result->hasAggregations()) {
- foreach ($this->result->getAggregations() as $aggregationName => $aggregation) {
- $this->facets[$aggregationName] = $this->objectManager->get(
- Facet::class,
- $aggregationName,
- $aggregation
- );
- }
+
+ if ($this->result->hasAggregations() === false) {
+ return;
+ }
+
+ foreach ($this->result->getAggregations() as $aggregationName => $aggregation) {
+ $this->facets[$aggregationName] = $this->objectManager->get(
+ Facet::class,
+ $aggregationName,
+ $aggregation
+ );
}
}
From 12c3623dff824ea675fec3bea173d45bf1a31a92 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 18:08:00 +0100
Subject: [PATCH 58/73] TASK: Cleanup TypoScript
Do not provide unnecessary Constants or Setup.
Fluid paths are there out of the box and integrators have all freedom
without the provided constants.
---
Configuration/TypoScript/constants.typoscript | 6 ------
Configuration/TypoScript/setup.typoscript | 8 --------
2 files changed, 14 deletions(-)
diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript
index 7ff92dbc..136d4dda 100644
--- a/Configuration/TypoScript/constants.typoscript
+++ b/Configuration/TypoScript/constants.typoscript
@@ -1,10 +1,4 @@
plugin.tx_searchcore {
- view {
- templateRootPath = EXT:search_core/Resources/Private/Templates
- partialRootPath = EXT:search_core/Resources/Private/Partials
- layoutRootPath = EXT:search_core/Resources/Private/Layouts
- }
-
settings {
connections {
elasticsearch {
diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript
index 7ff8d295..dd31866b 100644
--- a/Configuration/TypoScript/setup.typoscript
+++ b/Configuration/TypoScript/setup.typoscript
@@ -1,13 +1,5 @@
plugin.tx_searchcore {
- view {
- templateRootPaths.10 = {$plugin.tx_searchcore.view.templateRootPath}
- partialRootPaths.10 = {$plugin.tx_searchcore.view.partialRootPath}
- layoutRootPaths.10 = {$plugin.tx_searchcore.view.layoutRootPath}
- }
-
settings {
- searchOverview = {$plugin.tx_searchcore.settings.searchOverview}
-
connections {
elasticsearch {
host = {$plugin.tx_searchcore.settings.connections.elasticsearch.host}
From 89a558e73589ab0b517f2b385cf185e8c9b25c18 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 18:44:38 +0100
Subject: [PATCH 59/73] TASK: Improve documentation
* Add some missing documentation.
* Adjust some documentation due to breaking changes.
* Adjust structure of documentation for easier changelog rendering and
browsing.
---
Classes/Command/IndexCommandController.php | 4 +--
Documentation/source/changelog.rst | 18 ++--------
Documentation/source/changelog/0.0.8.rst | 16 +++++++++
.../20180306-120-facet-configuration.rst | 0
.../20180308-131-respect-page-cache-clear.rst | 0
.../20180308-introduce-php70-type-hints.rst | 0
.../20180309-25-provide-sys-language-uid.rst | 0
...15-134-make-conent-fields-configurable.rst | 0
.../20180410-148-keep-sys_language_uid.rst | 0
...t-relation-resolver-to-data-processing.rst | 0
...180518-75-make-index-name-configurable.rst | 0
...-allow-zero-as-typoscript-filter-value.rst | 0
...e-pluginname-in-configurationcontainer.rst | 0
Documentation/source/changelog/0.1.0.rst | 15 ++++++++
.../2018-added-content-element-wizard.rst | 5 +++
.../0.1.0/2018-changed-interfaces.rst | 31 ++++++++++++++++
.../0.1.0/2018-elasticsearch-upgrade.rst | 9 +++++
.../0.1.0/2018-search-service-interface.rst | 23 ++++++++++++
.../20181027-added-flush-command.rst | 0
...81027-allow-multiple-identifier-on-cli.rst | 13 +++++++
.../20181027-remove-cms7-support.rst | 4 +--
.../20181028-fluid-templating-list-items.rst | 28 +++++++++++++++
...20181227-rename-of-configuration-files.rst | 6 ++++
...81027-allow-multiple-identifier-on-cli.rst | 4 ---
.../20181028-fluid-templating-list-items.rst | 24 -------------
Documentation/source/configuration.rst | 4 +--
Documentation/source/usage.rst | 35 ++++++++++++++-----
27 files changed, 182 insertions(+), 57 deletions(-)
create mode 100644 Documentation/source/changelog/0.0.8.rst
rename Documentation/source/changelog/{ => 0.0.8}/20180306-120-facet-configuration.rst (100%)
rename Documentation/source/changelog/{ => 0.0.8}/20180308-131-respect-page-cache-clear.rst (100%)
rename Documentation/source/changelog/{ => 0.0.8}/20180308-introduce-php70-type-hints.rst (100%)
rename Documentation/source/changelog/{ => 0.0.8}/20180309-25-provide-sys-language-uid.rst (100%)
rename Documentation/source/changelog/{ => 0.0.8}/20180315-134-make-conent-fields-configurable.rst (100%)
rename Documentation/source/changelog/{ => 0.0.8}/20180410-148-keep-sys_language_uid.rst (100%)
rename Documentation/source/changelog/{ => 0.0.8}/20180424-149-extract-relation-resolver-to-data-processing.rst (100%)
rename Documentation/source/changelog/{ => 0.0.8}/20180518-75-make-index-name-configurable.rst (100%)
rename Documentation/source/changelog/{ => 0.0.8}/20180926-163-allow-zero-as-typoscript-filter-value.rst (100%)
rename Documentation/source/changelog/{ => 0.0.8}/20181106-170-do-not-specify-the-pluginname-in-configurationcontainer.rst (100%)
create mode 100644 Documentation/source/changelog/0.1.0.rst
create mode 100644 Documentation/source/changelog/0.1.0/2018-added-content-element-wizard.rst
create mode 100644 Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
create mode 100644 Documentation/source/changelog/0.1.0/2018-elasticsearch-upgrade.rst
create mode 100644 Documentation/source/changelog/0.1.0/2018-search-service-interface.rst
rename Documentation/source/changelog/{ => 0.1.0}/20181027-added-flush-command.rst (100%)
create mode 100644 Documentation/source/changelog/0.1.0/20181027-allow-multiple-identifier-on-cli.rst
rename Documentation/source/changelog/{ => 0.1.0}/20181027-remove-cms7-support.rst (56%)
create mode 100644 Documentation/source/changelog/0.1.0/20181028-fluid-templating-list-items.rst
create mode 100644 Documentation/source/changelog/0.1.0/20181227-rename-of-configuration-files.rst
delete mode 100644 Documentation/source/changelog/20181027-allow-multiple-identifier-on-cli.rst
delete mode 100644 Documentation/source/changelog/20181028-fluid-templating-list-items.rst
diff --git a/Classes/Command/IndexCommandController.php b/Classes/Command/IndexCommandController.php
index 8e1f370c..dff0fb36 100644
--- a/Classes/Command/IndexCommandController.php
+++ b/Classes/Command/IndexCommandController.php
@@ -72,7 +72,7 @@ public function deleteCommand(string $identifiers)
}
/**
- * Will delete the full index for given identifiers.
+ * Will flush the index for given identifiers from backend.
*
* @param string $identifier Comma separated list of identifiers.
*/
@@ -80,7 +80,7 @@ public function flushCommand(string $identifiers = 'pages')
{
$this->executeForIdentifier($identifiers, function (IndexerInterface $indexer) {
$indexer->delete();
- $this->outputLine('Indice ' . $indexer->getIdentifier() . ' was deleted.');
+ $this->outputLine('Indice ' . $indexer->getIdentifier() . ' was flushed.');
});
}
diff --git a/Documentation/source/changelog.rst b/Documentation/source/changelog.rst
index 9d226f78..fadb7d28 100644
--- a/Documentation/source/changelog.rst
+++ b/Documentation/source/changelog.rst
@@ -2,19 +2,7 @@ Changelog
=========
.. toctree::
- :maxdepth: 1
- :glob:
+ :maxdepth: 2
- changelog/20181027-added-flush-command
- changelog/20181027-allow-multiple-identifiers-on-cli
- changelog/20181027-remove-cms7-support
- changelog/20180518-75-make-index-name-configurable
- changelog/20180424-149-extract-relation-resolver-to-data-processing
- changelog/20180410-148-keep-sys_language_uid
- changelog/20180315-134-make-conent-fields-configurable
- changelog/20180309-25-provide-sys-language-uid
- changelog/20180308-131-respect-page-cache-clear
- changelog/20180308-introduce-php70-type-hints
- changelog/20180306-120-facet-configuration
- changelog/20180926-163-allow-zero-as-typoscript-filter-value
- changelog/20181106-170-do-not-specify-the-pluginname-in-configurationcontainer
+ changelog/0.1.0
+ changelog/0.0.8
diff --git a/Documentation/source/changelog/0.0.8.rst b/Documentation/source/changelog/0.0.8.rst
new file mode 100644
index 00000000..03ce022a
--- /dev/null
+++ b/Documentation/source/changelog/0.0.8.rst
@@ -0,0 +1,16 @@
+Up till v0.0.8
+==============
+
+.. toctree::
+ :maxdepth: 1
+
+ 0.0.8/20180306-120-facet-configuration
+ 0.0.8/20180308-131-respect-page-cache-clear
+ 0.0.8/20180308-introduce-php70-type-hints
+ 0.0.8/20180309-25-provide-sys-language-uid
+ 0.0.8/20180315-134-make-conent-fields-configurable
+ 0.0.8/20180410-148-keep-sys_language_uid
+ 0.0.8/20180424-149-extract-relation-resolver-to-data-processing
+ 0.0.8/20180518-75-make-index-name-configurable
+ 0.0.8/20180926-163-allow-zero-as-typoscript-filter-value
+ 0.0.8/20181106-170-do-not-specify-the-pluginname-in-configurationcontainer
diff --git a/Documentation/source/changelog/20180306-120-facet-configuration.rst b/Documentation/source/changelog/0.0.8/20180306-120-facet-configuration.rst
similarity index 100%
rename from Documentation/source/changelog/20180306-120-facet-configuration.rst
rename to Documentation/source/changelog/0.0.8/20180306-120-facet-configuration.rst
diff --git a/Documentation/source/changelog/20180308-131-respect-page-cache-clear.rst b/Documentation/source/changelog/0.0.8/20180308-131-respect-page-cache-clear.rst
similarity index 100%
rename from Documentation/source/changelog/20180308-131-respect-page-cache-clear.rst
rename to Documentation/source/changelog/0.0.8/20180308-131-respect-page-cache-clear.rst
diff --git a/Documentation/source/changelog/20180308-introduce-php70-type-hints.rst b/Documentation/source/changelog/0.0.8/20180308-introduce-php70-type-hints.rst
similarity index 100%
rename from Documentation/source/changelog/20180308-introduce-php70-type-hints.rst
rename to Documentation/source/changelog/0.0.8/20180308-introduce-php70-type-hints.rst
diff --git a/Documentation/source/changelog/20180309-25-provide-sys-language-uid.rst b/Documentation/source/changelog/0.0.8/20180309-25-provide-sys-language-uid.rst
similarity index 100%
rename from Documentation/source/changelog/20180309-25-provide-sys-language-uid.rst
rename to Documentation/source/changelog/0.0.8/20180309-25-provide-sys-language-uid.rst
diff --git a/Documentation/source/changelog/20180315-134-make-conent-fields-configurable.rst b/Documentation/source/changelog/0.0.8/20180315-134-make-conent-fields-configurable.rst
similarity index 100%
rename from Documentation/source/changelog/20180315-134-make-conent-fields-configurable.rst
rename to Documentation/source/changelog/0.0.8/20180315-134-make-conent-fields-configurable.rst
diff --git a/Documentation/source/changelog/20180410-148-keep-sys_language_uid.rst b/Documentation/source/changelog/0.0.8/20180410-148-keep-sys_language_uid.rst
similarity index 100%
rename from Documentation/source/changelog/20180410-148-keep-sys_language_uid.rst
rename to Documentation/source/changelog/0.0.8/20180410-148-keep-sys_language_uid.rst
diff --git a/Documentation/source/changelog/20180424-149-extract-relation-resolver-to-data-processing.rst b/Documentation/source/changelog/0.0.8/20180424-149-extract-relation-resolver-to-data-processing.rst
similarity index 100%
rename from Documentation/source/changelog/20180424-149-extract-relation-resolver-to-data-processing.rst
rename to Documentation/source/changelog/0.0.8/20180424-149-extract-relation-resolver-to-data-processing.rst
diff --git a/Documentation/source/changelog/20180518-75-make-index-name-configurable.rst b/Documentation/source/changelog/0.0.8/20180518-75-make-index-name-configurable.rst
similarity index 100%
rename from Documentation/source/changelog/20180518-75-make-index-name-configurable.rst
rename to Documentation/source/changelog/0.0.8/20180518-75-make-index-name-configurable.rst
diff --git a/Documentation/source/changelog/20180926-163-allow-zero-as-typoscript-filter-value.rst b/Documentation/source/changelog/0.0.8/20180926-163-allow-zero-as-typoscript-filter-value.rst
similarity index 100%
rename from Documentation/source/changelog/20180926-163-allow-zero-as-typoscript-filter-value.rst
rename to Documentation/source/changelog/0.0.8/20180926-163-allow-zero-as-typoscript-filter-value.rst
diff --git a/Documentation/source/changelog/20181106-170-do-not-specify-the-pluginname-in-configurationcontainer.rst b/Documentation/source/changelog/0.0.8/20181106-170-do-not-specify-the-pluginname-in-configurationcontainer.rst
similarity index 100%
rename from Documentation/source/changelog/20181106-170-do-not-specify-the-pluginname-in-configurationcontainer.rst
rename to Documentation/source/changelog/0.0.8/20181106-170-do-not-specify-the-pluginname-in-configurationcontainer.rst
diff --git a/Documentation/source/changelog/0.1.0.rst b/Documentation/source/changelog/0.1.0.rst
new file mode 100644
index 00000000..036a2222
--- /dev/null
+++ b/Documentation/source/changelog/0.1.0.rst
@@ -0,0 +1,15 @@
+v0.1.0
+======
+
+.. toctree::
+ :maxdepth: 1
+
+ 0.1.0/2018-added-content-element-wizard
+ 0.1.0/2018-changed-interfaces
+ 0.1.0/2018-elasticsearch-upgrade
+ 0.1.0/2018-search-service-interface
+ 0.1.0/20181027-added-flush-command
+ 0.1.0/20181027-allow-multiple-identifier-on-cli
+ 0.1.0/20181027-remove-cms7-support
+ 0.1.0/20181028-fluid-templating-list-items
+ 0.1.0/20181227-rename-of-configuration-files
diff --git a/Documentation/source/changelog/0.1.0/2018-added-content-element-wizard.rst b/Documentation/source/changelog/0.1.0/2018-added-content-element-wizard.rst
new file mode 100644
index 00000000..4fc2dac3
--- /dev/null
+++ b/Documentation/source/changelog/0.1.0/2018-added-content-element-wizard.rst
@@ -0,0 +1,5 @@
+Feature: "Added content element wizard entry"
+=============================================
+
+The search core plugin is now selectable from the content element wizard by default.
+Therefore the necessary PageTSConfig is added by default.
diff --git a/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst b/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
new file mode 100644
index 00000000..993b7da8
--- /dev/null
+++ b/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
@@ -0,0 +1,31 @@
+Breaking Change "Changed interfaces"
+====================================
+
+Some interfaces and abstract classes have been adjusted:
+
+``Codappix\SearchCore\Connection\ConnectionInterface``:
+
+ * New method ``public function deleteIndexByDocumentType(string $documentType);``
+
+``Codappix\SearchCore\Domain\Index\IndexerInterface``:
+
+ * New method ``public function deleteDocuments();``
+
+ * New method ``public function getIdentifier(): string;``
+
+``Codappix\SearchCore\Domain\Index\AbstractIndexer``:
+
+ * New method ``abstract public function getDocumentIdentifier($identifier): string;``
+
+``Codappix\SearchCore\Connection\SearchRequestInterface``:
+
+ * Changed method signature from ``public function setSearchService(SearchService $searchService);``
+ to ``public function setSearchService(SearchServiceInterface $searchService);``
+
+Also some exceptions have changed:
+
+* ``Codappix\SearchCore\Connection\Elasticsearch\DocumentFactory::getDocument()`` now
+throws an ``\InvalidArgumentException`` instead of ``\Exception``, if no
+``search_identifier`` was provided.
+
+
diff --git a/Documentation/source/changelog/0.1.0/2018-elasticsearch-upgrade.rst b/Documentation/source/changelog/0.1.0/2018-elasticsearch-upgrade.rst
new file mode 100644
index 00000000..bfc7e45c
--- /dev/null
+++ b/Documentation/source/changelog/0.1.0/2018-elasticsearch-upgrade.rst
@@ -0,0 +1,9 @@
+Breaking Change "Elasticsearch Upgrade"
+=======================================
+
+By now Elasticsearch v6.x is required in order to work.
+
+You might need to change some configuration, as this is just piped through to
+Elasticsearch. Check out the breaking changes of Elasticsearch from 5.x to 6.x.
+
+Also update your Elasticsearch instance.
diff --git a/Documentation/source/changelog/0.1.0/2018-search-service-interface.rst b/Documentation/source/changelog/0.1.0/2018-search-service-interface.rst
new file mode 100644
index 00000000..056bcb3d
--- /dev/null
+++ b/Documentation/source/changelog/0.1.0/2018-search-service-interface.rst
@@ -0,0 +1,23 @@
+Feature "SearchServiceInterface"
+================================
+
+The concrete search service can now be exchanged. Therefore a new Interface was
+introduced::
+
+ namespace Codappix\SearchCore\Domain\Search;
+
+ use Codappix\SearchCore\Connection\SearchRequestInterface;
+ use Codappix\SearchCore\Connection\SearchResultInterface;
+
+ interface SearchServiceInterface
+ {
+ /**
+ * Fetches result for provided search request.
+ */
+ public function search(SearchRequestInterface $searchRequest): SearchResultInterface;
+
+ /**
+ * Processes the result, e.g. applies configured data processing to result.
+ */
+ public function processResult(SearchResultInterface $searchResult): SearchResultInterface;
+ }
diff --git a/Documentation/source/changelog/20181027-added-flush-command.rst b/Documentation/source/changelog/0.1.0/20181027-added-flush-command.rst
similarity index 100%
rename from Documentation/source/changelog/20181027-added-flush-command.rst
rename to Documentation/source/changelog/0.1.0/20181027-added-flush-command.rst
diff --git a/Documentation/source/changelog/0.1.0/20181027-allow-multiple-identifier-on-cli.rst b/Documentation/source/changelog/0.1.0/20181027-allow-multiple-identifier-on-cli.rst
new file mode 100644
index 00000000..952e12fe
--- /dev/null
+++ b/Documentation/source/changelog/0.1.0/20181027-allow-multiple-identifier-on-cli.rst
@@ -0,0 +1,13 @@
+Breaking Change "Allow multiple identifiers on cli"
+===================================================
+
+All CLI commands except a comma separated list of IDs now. Still single IDs are allowed.
+
+Each Identifier will be processed one by another. This is just for continence to not
+call the command multiple times with different identifiers.
+
+Spaces are ignored before and after commas.
+
+
+As the argument was renamed from ``--identifier`` to ``--identifiers``, this is
+considered a breaking change.
diff --git a/Documentation/source/changelog/20181027-remove-cms7-support.rst b/Documentation/source/changelog/0.1.0/20181027-remove-cms7-support.rst
similarity index 56%
rename from Documentation/source/changelog/20181027-remove-cms7-support.rst
rename to Documentation/source/changelog/0.1.0/20181027-remove-cms7-support.rst
index ec493f1d..e62d50e4 100644
--- a/Documentation/source/changelog/20181027-remove-cms7-support.rst
+++ b/Documentation/source/changelog/0.1.0/20181027-remove-cms7-support.rst
@@ -1,5 +1,5 @@
-Breaking Change "Remove CMS7 support"
-=====================================
+Breaking Change "Removed CMS7 support"
+======================================
We no longer support TYPO3 CMS 7.x.
diff --git a/Documentation/source/changelog/0.1.0/20181028-fluid-templating-list-items.rst b/Documentation/source/changelog/0.1.0/20181028-fluid-templating-list-items.rst
new file mode 100644
index 00000000..7094ff22
--- /dev/null
+++ b/Documentation/source/changelog/0.1.0/20181028-fluid-templating-list-items.rst
@@ -0,0 +1,28 @@
+Feature "Added fluid partials for list items"
+=============================================
+
+When using a separate partial for ListItem you can simply adjust for your custom page type:
+
+Example ListItem.html::
+-----------------------
+.. code-block:: html
+ :linenos:
+
+
+
+
+ Add opening for possible different partials based on Document types:
+
+
+ {f:render(partial: 'resultItem-{result.search_document_type}', arguments: {result: result)}
+
+
+ // Render pages
+
+
+
+ // Render custom "documentType"
+
+
+
diff --git a/Documentation/source/changelog/0.1.0/20181227-rename-of-configuration-files.rst b/Documentation/source/changelog/0.1.0/20181227-rename-of-configuration-files.rst
new file mode 100644
index 00000000..2aa71d8d
--- /dev/null
+++ b/Documentation/source/changelog/0.1.0/20181227-rename-of-configuration-files.rst
@@ -0,0 +1,6 @@
+Breaking Change "Configuration files were renamed"
+==================================================
+
+TypoScript configuration files now end with ``.typoscript`` instead of ``.txt``.
+
+If you require these files via include statements with full file name, these need to be adjusted.
diff --git a/Documentation/source/changelog/20181027-allow-multiple-identifier-on-cli.rst b/Documentation/source/changelog/20181027-allow-multiple-identifier-on-cli.rst
deleted file mode 100644
index bab42117..00000000
--- a/Documentation/source/changelog/20181027-allow-multiple-identifier-on-cli.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-Feature "Allow multiple identifiers on cli"
-===========================================
-
-All CLI commands except a comma separated list of IDs now.
diff --git a/Documentation/source/changelog/20181028-fluid-templating-list-items.rst b/Documentation/source/changelog/20181028-fluid-templating-list-items.rst
deleted file mode 100644
index 05501805..00000000
--- a/Documentation/source/changelog/20181028-fluid-templating-list-items.rst
+++ /dev/null
@@ -1,24 +0,0 @@
-Feature "Added fluid partials for list items"
-=============================================
-
-When using a seperate partial for ListItem you can simply adjust for your custom page type:
-
-Example ListItem.html::
------------------------
-.. code-block:: html
- :linenos:
-
-
-
-
- Add opening for possible different partials based on Document types:
-
-
-
- {f:render(partial: 'Results/Item/YourDocumentType', arguments: {result: result})}
- {f:render(partial: 'Results/Item/Page', arguments: {result: result})}
- {f:render(partial: 'Results/Item/Unknown', arguments: {result: result})}
-
-
-
diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst
index 53ac469b..78910086 100644
--- a/Documentation/source/configuration.rst
+++ b/Documentation/source/configuration.rst
@@ -24,11 +24,11 @@ The structure is following TYPO3 Extbase conventions. All settings are placed in
Here is the example default configuration that's provided through static include:
-.. literalinclude:: ../../Configuration/TypoScript/constants.txt
+.. literalinclude:: ../../Configuration/TypoScript/constants.typoscript
:language: typoscript
:caption: Static TypoScript Constants
-.. literalinclude:: ../../Configuration/TypoScript/setup.txt
+.. literalinclude:: ../../Configuration/TypoScript/setup.typoscript
:language: typoscript
:caption: Static TypoScript Setup
diff --git a/Documentation/source/usage.rst b/Documentation/source/usage.rst
index fc6d08a3..8e0d93c5 100644
--- a/Documentation/source/usage.rst
+++ b/Documentation/source/usage.rst
@@ -11,12 +11,13 @@ Manual indexing
You can trigger indexing from CLI::
- ./typo3/cli_dispatch.phpsh extbase index:index --identifier 'pages'
- ./bin/typo3cms index:index --identifier 'pages'
+ ./typo3/cli_dispatch.phpsh extbase index:index --identifiers 'pages'
+ ./bin/typo3cms index:index --identifiers 'pages'
This will index the table ``pages`` using the :ref:`TcaIndexer`.
-Only one index per call is available, to run multiple indexers, just make multiple calls.
+Multiple indexer can be called by providing a comma separated list of identifiers as
+a single argument. Spaces before and after commas are ignored.
The indexers have to be defined in TypoScript via :ref:`configuration_options_index`.
.. _usage_manual_deletion:
@@ -24,14 +25,32 @@ The indexers have to be defined in TypoScript via :ref:`configuration_options_in
Manual deletion
---------------
-You can trigger deletion for a single index from CLI::
+You can trigger deletion for indexes from CLI::
- ./typo3/cli_dispatch.phpsh extbase index:delete --identifier 'pages'
- ./bin/typo3cms index:delete --identifier 'pages'
+ ./typo3/cli_dispatch.phpsh extbase index:delete --identifiers 'pages'
+ ./bin/typo3cms index:delete --identifiers 'pages'
-This will delete the index for the table ``pages``.
+This will delete the index for the table ``pages``. Deletion means removing all
+documents from the index.
-Only one delete per call is available, to run multiple deletions, just make multiple calls.
+Multiple indices can be called by providing a comma separated list of identifiers as
+a single argument. Spaces before and after commas are ignored.
+
+.. _usage_manual_flush:
+
+Manual flush
+------------
+
+You can trigger flush for indexes from CLI::
+
+ ./typo3/cli_dispatch.phpsh extbase index:flush --identifiers 'pages'
+ ./bin/typo3cms index:flush --identifiers 'pages'
+
+This will flush the index for the table ``pages``. Flush means removing the index
+from backend.
+
+Multiple indices can be called by providing a comma separated list of identifiers as
+a single argument. Spaces before and after commas are ignored.
.. _usage_auto_indexing:
From 831da6a4e46abfe62c82c9a0d97774a1f4099184 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 19:21:58 +0100
Subject: [PATCH 60/73] TASK: Use new SearchRequestInterface everywhere
Otherwise the interface is no big benefit. Also it might crash under
some circumstances.
---
Classes/Connection/SearchRequestInterface.php | 4 ++--
Classes/Domain/Model/SearchRequest.php | 8 ++++----
Tests/Unit/Domain/Model/SearchRequestTest.php | 7 +++----
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/Classes/Connection/SearchRequestInterface.php b/Classes/Connection/SearchRequestInterface.php
index d6778862..221f078d 100644
--- a/Classes/Connection/SearchRequestInterface.php
+++ b/Classes/Connection/SearchRequestInterface.php
@@ -21,7 +21,7 @@
* 02110-1301, USA.
*/
-use Codappix\SearchCore\Domain\Search\SearchService;
+use Codappix\SearchCore\Domain\Search\SearchServiceInterface;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
interface SearchRequestInterface extends QueryInterface
@@ -54,5 +54,5 @@ public function setConnection(ConnectionInterface $connection);
* Workaround for paginate widget support which will
* use the request to build another search.
*/
- public function setSearchService(SearchService $searchService);
+ public function setSearchService(SearchServiceInterface $searchService);
}
diff --git a/Classes/Domain/Model/SearchRequest.php b/Classes/Domain/Model/SearchRequest.php
index fa05904b..0d8865b1 100644
--- a/Classes/Domain/Model/SearchRequest.php
+++ b/Classes/Domain/Model/SearchRequest.php
@@ -25,7 +25,7 @@
use Codappix\SearchCore\Connection\FacetRequestInterface;
use Codappix\SearchCore\Connection\SearchRequestInterface;
use Codappix\SearchCore\Connection\SearchResultInterface;
-use Codappix\SearchCore\Domain\Search\SearchService;
+use Codappix\SearchCore\Domain\Search\SearchServiceInterface;
use Codappix\SearchCore\Utility\ArrayUtility as CustomArrayUtility;
use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -69,7 +69,7 @@ class SearchRequest implements SearchRequestInterface
protected $connection;
/**
- * @var SearchService
+ * @var SearchServiceInterface
*/
protected $searchService;
@@ -137,7 +137,7 @@ public function setConnection(ConnectionInterface $connection)
$this->connection = $connection;
}
- public function setSearchService(SearchService $searchService)
+ public function setSearchService(SearchServiceInterface $searchService)
{
$this->searchService = $searchService;
}
@@ -156,7 +156,7 @@ public function execute($returnRawQueryResult = false)
1502197732
);
}
- if (!($this->searchService instanceof SearchService)) {
+ if (!($this->searchService instanceof SearchServiceInterface)) {
throw new \InvalidArgumentException(
'SearchService was not set before, therefore execute can not work. Use `setSearchService` before.',
1520325175
diff --git a/Tests/Unit/Domain/Model/SearchRequestTest.php b/Tests/Unit/Domain/Model/SearchRequestTest.php
index 9dcc3139..30e24959 100644
--- a/Tests/Unit/Domain/Model/SearchRequestTest.php
+++ b/Tests/Unit/Domain/Model/SearchRequestTest.php
@@ -24,7 +24,7 @@
use Codappix\SearchCore\Connection\ConnectionInterface;
use Codappix\SearchCore\Connection\SearchResultInterface;
use Codappix\SearchCore\Domain\Model\SearchRequest;
-use Codappix\SearchCore\Domain\Search\SearchService;
+use Codappix\SearchCore\Domain\Search\SearchServiceInterface;
use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase;
class SearchRequestTest extends AbstractUnitTestCase
@@ -105,7 +105,7 @@ public function exceptionIsThrownIfConnectionWasNotSet()
{
$subject = new SearchRequest();
$subject->setSearchService(
- $this->getMockBuilder(SearchService::class)
+ $this->getMockBuilder(SearchServiceInterface::class)
->disableOriginalConstructor()
->getMock()
);
@@ -118,8 +118,7 @@ public function exceptionIsThrownIfConnectionWasNotSet()
*/
public function executionMakesUseOfProvidedConnectionAndSearchService()
{
- $searchServiceMock = $this->getMockBuilder(SearchService::class)
- ->disableOriginalConstructor()
+ $searchServiceMock = $this->getMockBuilder(SearchServiceInterface::class)
->getMock();
$connectionMock = $this->getMockBuilder(ConnectionInterface::class)
->getMock();
From f95723fff74cb62f7d37a9f68270f514c896c20c Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 19:23:46 +0100
Subject: [PATCH 61/73] TASK: Fix unit tests
---
Tests/Unit/Command/IndexCommandControllerTest.php | 2 +-
Tests/Unit/Controller/SearchControllerTest.php | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Tests/Unit/Command/IndexCommandControllerTest.php b/Tests/Unit/Command/IndexCommandControllerTest.php
index 7a18f055..d722f6df 100644
--- a/Tests/Unit/Command/IndexCommandControllerTest.php
+++ b/Tests/Unit/Command/IndexCommandControllerTest.php
@@ -131,7 +131,7 @@ public function flushIsPossible()
->willReturn('pages');
$this->subject->expects($this->once())
->method('outputLine')
- ->with('Indice pages was deleted.');
+ ->with('Indice pages was flushed.');
$this->indexerFactory->expects($this->once())
->method('getIndexer')
->with('pages')
diff --git a/Tests/Unit/Controller/SearchControllerTest.php b/Tests/Unit/Controller/SearchControllerTest.php
index ba1d2af7..0357b868 100644
--- a/Tests/Unit/Controller/SearchControllerTest.php
+++ b/Tests/Unit/Controller/SearchControllerTest.php
@@ -76,7 +76,7 @@ public function searchRequestArgumentIsAddedIfModeIsFilterAndArgumentDoesNotExis
]
]);
- $this->subject->initializeResultsAction();
+ $this->subject->initializeSearchAction();
$this->assertInstanceOf(
SearchRequest::class,
$this->request->getArgument('searchRequest'),
@@ -100,7 +100,7 @@ public function searchRequestArgumentIsAddedToExistingArguments()
]
]);
- $this->subject->initializeResultsAction();
+ $this->subject->initializeSearchAction();
$this->assertInstanceOf(
SearchRequest::class,
$this->request->getArgument('searchRequest'),
@@ -120,7 +120,7 @@ public function searchRequestArgumentIsNotAddedIfModeIsNotFilter()
{
$this->inject($this->subject, 'settings', ['searching' => []]);
- $this->subject->initializeResultsAction();
+ $this->subject->initializeSearchAction();
$this->assertFalse(
$this->request->hasArgument('searchRequest'),
'Search request should not exist.'
From 97160dac91df53028add8b17df6205a0ee0b8f03 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 19:24:07 +0100
Subject: [PATCH 62/73] TASK: Use php 7 anonymous function call
---
Configuration/TCA/Overrides/tt_content.php | 8 +++-----
ext_localconf.php | 4 ++--
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php
index 5bb389a8..de606bb5 100644
--- a/Configuration/TCA/Overrides/tt_content.php
+++ b/Configuration/TCA/Overrides/tt_content.php
@@ -1,9 +1,7 @@
Date: Sat, 29 Dec 2018 19:27:02 +0100
Subject: [PATCH 63/73] TASK: Remove unused file / php class
---
.../Search/MissingAttributeException.php | 26 -------------------
1 file changed, 26 deletions(-)
delete mode 100644 Classes/Domain/Search/MissingAttributeException.php
diff --git a/Classes/Domain/Search/MissingAttributeException.php b/Classes/Domain/Search/MissingAttributeException.php
deleted file mode 100644
index f47e3695..00000000
--- a/Classes/Domain/Search/MissingAttributeException.php
+++ /dev/null
@@ -1,26 +0,0 @@
-
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-class MissingAttributeException extends \InvalidArgumentException
-{
-}
From 43254c168c724ff049afeefa4fbd0795be6ce633 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sat, 29 Dec 2018 19:27:47 +0100
Subject: [PATCH 64/73] TASK: Fix license and php doc
---
Classes/Domain/Search/CachedSearchService.php | 3 +--
Classes/Utility/ArrayUtility.php | 21 ++++++++++++++++---
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/Classes/Domain/Search/CachedSearchService.php b/Classes/Domain/Search/CachedSearchService.php
index db94c841..a8655f3c 100644
--- a/Classes/Domain/Search/CachedSearchService.php
+++ b/Classes/Domain/Search/CachedSearchService.php
@@ -26,8 +26,7 @@
use TYPO3\CMS\Core\SingletonInterface;
/**
- * Service: Cached Search
- * @package Codappix\SearchCore\Domain\Search
+ * Service to process a search request, only once per request.
*/
class CachedSearchService implements SingletonInterface, SearchServiceInterface
{
diff --git a/Classes/Utility/ArrayUtility.php b/Classes/Utility/ArrayUtility.php
index e77c056d..91e9e47c 100644
--- a/Classes/Utility/ArrayUtility.php
+++ b/Classes/Utility/ArrayUtility.php
@@ -2,10 +2,25 @@
namespace Codappix\SearchCore\Utility;
-/**
- * Utility: Array
- * @package Codappix\SearchCore\Utility
+/*
+ * Copyright (C) 2018 Benjamin Serfhos
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
*/
+
class ArrayUtility
{
/**
From 28a8dd1ab40751fd60e0f68f4c01c90b35ebe153 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sun, 30 Dec 2018 13:22:25 +0100
Subject: [PATCH 65/73] TASK: rephrase indice to index.
---
Classes/Command/IndexCommandController.php | 4 ++--
Documentation/source/usage.rst | 4 ++--
Tests/Unit/Command/IndexCommandControllerTest.php | 14 +++++++-------
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Classes/Command/IndexCommandController.php b/Classes/Command/IndexCommandController.php
index dff0fb36..b01800ee 100644
--- a/Classes/Command/IndexCommandController.php
+++ b/Classes/Command/IndexCommandController.php
@@ -54,7 +54,7 @@ public function indexCommand(string $identifiers)
{
$this->executeForIdentifier($identifiers, function (IndexerInterface $indexer) {
$indexer->indexAllDocuments();
- $this->outputLine('Documents in indice ' . $indexer->getIdentifier() . ' were indexed.');
+ $this->outputLine('Documents in index ' . $indexer->getIdentifier() . ' were indexed.');
});
}
@@ -67,7 +67,7 @@ public function deleteCommand(string $identifiers)
{
$this->executeForIdentifier($identifiers, function (IndexerInterface $indexer) {
$indexer->deleteDocuments();
- $this->outputLine('Documents in indice ' . $indexer->getIdentifier() . ' were deleted.');
+ $this->outputLine('Documents in index ' . $indexer->getIdentifier() . ' were deleted.');
});
}
diff --git a/Documentation/source/usage.rst b/Documentation/source/usage.rst
index 8e0d93c5..687ae2d0 100644
--- a/Documentation/source/usage.rst
+++ b/Documentation/source/usage.rst
@@ -33,7 +33,7 @@ You can trigger deletion for indexes from CLI::
This will delete the index for the table ``pages``. Deletion means removing all
documents from the index.
-Multiple indices can be called by providing a comma separated list of identifiers as
+Multiple indexes can be called by providing a comma separated list of identifiers as
a single argument. Spaces before and after commas are ignored.
.. _usage_manual_flush:
@@ -49,7 +49,7 @@ You can trigger flush for indexes from CLI::
This will flush the index for the table ``pages``. Flush means removing the index
from backend.
-Multiple indices can be called by providing a comma separated list of identifiers as
+Multiple indexes can be called by providing a comma separated list of identifiers as
a single argument. Spaces before and after commas are ignored.
.. _usage_auto_indexing:
diff --git a/Tests/Unit/Command/IndexCommandControllerTest.php b/Tests/Unit/Command/IndexCommandControllerTest.php
index d722f6df..2b52109b 100644
--- a/Tests/Unit/Command/IndexCommandControllerTest.php
+++ b/Tests/Unit/Command/IndexCommandControllerTest.php
@@ -85,7 +85,7 @@ public function indexerExecutesForAllowedTable()
->method('quit');
$this->subject->expects($this->once())
->method('outputLine')
- ->with('Documents in indice allowedTable were indexed.');
+ ->with('Documents in index allowedTable were indexed.');
$this->indexerFactory->expects($this->once())
->method('getIndexer')
->with('allowedTable')
@@ -107,7 +107,7 @@ public function deletionIsPossible()
->willReturn('allowedTable');
$this->subject->expects($this->once())
->method('outputLine')
- ->with('Documents in indice allowedTable were deleted.');
+ ->with('Documents in index allowedTable were deleted.');
$this->indexerFactory->expects($this->once())
->method('getIndexer')
->with('allowedTable')
@@ -131,7 +131,7 @@ public function flushIsPossible()
->willReturn('pages');
$this->subject->expects($this->once())
->method('outputLine')
- ->with('Indice pages was flushed.');
+ ->with('Index pages was deleted.');
$this->indexerFactory->expects($this->once())
->method('getIndexer')
->with('pages')
@@ -177,8 +177,8 @@ public function indexerExecutesForAllowedTables()
$this->subject->expects($this->exactly(2))
->method('outputLine')
->withConsecutive(
- ['Documents in indice allowedTable were indexed.'],
- ['Documents in indice anotherTable were indexed.']
+ ['Documents in index allowedTable were indexed.'],
+ ['Documents in index anotherTable were indexed.']
);
$this->indexerFactory->expects($this->exactly(2))
->method('getIndexer')
@@ -203,7 +203,7 @@ public function indexerSkipsEmptyIdentifier()
->method('quit');
$this->subject->expects($this->once())
->method('outputLine')
- ->with('Documents in indice allowedTable were indexed.');
+ ->with('Documents in index allowedTable were indexed.');
$this->indexerFactory->expects($this->once())
->method('getIndexer')
->with('allowedTable')
@@ -229,7 +229,7 @@ public function indexerSkipsAndOutputsNonExistingIdentifier()
->method('outputLine')
->withConsecutive(
['No indexer found for: nonExisting.'],
- ['Documents in indice allowedTable were indexed.']
+ ['Documents in index allowedTable were indexed.']
);
$this->indexerFactory->expects($this->exactly(2))
->method('getIndexer')
From 689f293194a6bdb935bdf68255a96aa26858be30 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sun, 30 Dec 2018 13:43:43 +0100
Subject: [PATCH 66/73] TASK: Finish deletion of index and documents feature
We replace the "flush" and "delete" by "delete" and "deletedocuments"
logic. This makes it more obvious what will happen, without reading the
docs.
Also we kept the logic to always provide the index name, as
we will need them in the future. Due to elasticsearch v6 changes no
types are allowed in the same index in the future. Therefore we need to
make it possible to use different indexes in the future, leading to the
need to provide the document type all the time.
---
Classes/Command/IndexCommandController.php | 10 +--
Classes/Connection/ConnectionInterface.php | 12 +--
Classes/Connection/Elasticsearch.php | 84 +++++++++----------
.../Connection/Elasticsearch/IndexFactory.php | 23 +++--
.../Connection/Elasticsearch/TypeFactory.php | 5 +-
Classes/Domain/Index/AbstractIndexer.php | 6 +-
Classes/Domain/Index/IndexerInterface.php | 4 +-
Documentation/source/changelog/0.1.0.rst | 2 +-
.../0.1.0/2018-changed-interfaces.rst | 10 ++-
...027-added-delete-all-documents-command.rst | 11 +++
.../0.1.0/20181027-added-flush-command.rst | 6 --
Documentation/source/usage.rst | 15 ++--
.../Elasticsearch/IndexDeletionTest.php | 6 +-
.../Command/IndexCommandControllerTest.php | 10 +--
.../Elasticsearch/IndexFactoryTest.php | 2 +-
15 files changed, 112 insertions(+), 94 deletions(-)
create mode 100644 Documentation/source/changelog/0.1.0/20181027-added-delete-all-documents-command.rst
delete mode 100644 Documentation/source/changelog/0.1.0/20181027-added-flush-command.rst
diff --git a/Classes/Command/IndexCommandController.php b/Classes/Command/IndexCommandController.php
index b01800ee..bed8af75 100644
--- a/Classes/Command/IndexCommandController.php
+++ b/Classes/Command/IndexCommandController.php
@@ -63,24 +63,24 @@ public function indexCommand(string $identifiers)
*
* @param string $identifier Comma separated list of identifiers.
*/
- public function deleteCommand(string $identifiers)
+ public function deleteDocumentsCommand(string $identifiers)
{
$this->executeForIdentifier($identifiers, function (IndexerInterface $indexer) {
- $indexer->deleteDocuments();
+ $indexer->deleteAllDocuments();
$this->outputLine('Documents in index ' . $indexer->getIdentifier() . ' were deleted.');
});
}
/**
- * Will flush the index for given identifiers from backend.
+ * Will delete the index for given identifiers.
*
* @param string $identifier Comma separated list of identifiers.
*/
- public function flushCommand(string $identifiers = 'pages')
+ public function deleteCommand(string $identifiers = 'pages')
{
$this->executeForIdentifier($identifiers, function (IndexerInterface $indexer) {
$indexer->delete();
- $this->outputLine('Indice ' . $indexer->getIdentifier() . ' was flushed.');
+ $this->outputLine('Index ' . $indexer->getIdentifier() . ' was deleted.');
});
}
diff --git a/Classes/Connection/ConnectionInterface.php b/Classes/Connection/ConnectionInterface.php
index 76122f8b..7677e7c3 100644
--- a/Classes/Connection/ConnectionInterface.php
+++ b/Classes/Connection/ConnectionInterface.php
@@ -51,17 +51,17 @@ public function updateDocument(string $documentType, array $document);
public function deleteDocument(string $documentType, string $identifier);
/**
- * Search by given request and return result.
+ * Will all documents of certain kind / in certain index.
*/
- public function search(SearchRequestInterface $searchRequest): SearchResultInterface;
+ public function deleteAllDocuments(string $documentType);
/**
- * Will delete the index / db of defined document type.
+ * Will delete the whole index / db.
*/
- public function deleteIndexByDocumentType(string $documentType);
+ public function deleteIndex(string $documentType);
/**
- * Will delete the whole index / db.
+ * Search by given request and return result.
*/
- public function deleteIndex();
+ public function search(SearchRequestInterface $searchRequest): SearchResultInterface;
}
diff --git a/Classes/Connection/Elasticsearch.php b/Classes/Connection/Elasticsearch.php
index 81e12584..0f85058e 100644
--- a/Classes/Connection/Elasticsearch.php
+++ b/Classes/Connection/Elasticsearch.php
@@ -142,6 +142,29 @@ function (Type $type, string $documentType) use ($identifier) {
}
}
+ public function deleteAllDocuments(string $documentType)
+ {
+ $this->deleteDocumentsByQuery($documentType, Query::create([
+ 'query' => [
+ 'term' => [
+ 'search_document_type' => $documentType,
+ ],
+ ],
+ ]));
+ }
+
+ public function deleteIndex(string $documentType)
+ {
+ try {
+ $this->indexFactory->getIndex($this->connection, $documentType)->delete();
+ } catch (\InvalidArgumentException $e) {
+ $this->logger->notice(
+ 'Index did not exist, therefore was not deleted.',
+ [$documentType, $e]
+ );
+ }
+ }
+
public function updateDocument(string $documentType, array $document)
{
$this->withType(
@@ -162,49 +185,6 @@ function (Type $type, string $documentType) use ($documents) {
);
}
- public function deleteIndex()
- {
- $index = $this->connection->getClient()->getIndex($this->indexFactory->getIndexName());
-
- if (!$index->exists()) {
- $this->logger->notice(
- 'Index did not exist, therefore was not deleted.',
- [$this->indexFactory->getIndexName()]
- );
- return;
- }
-
- $index->delete();
- }
-
- public function deleteIndexByDocumentType(string $documentType)
- {
- $this->deleteIndexByQuery(Query::create([
- 'query' => [
- 'term' => [
- 'search_document_type' => $documentType,
- ],
- ],
- ]));
- }
-
- private function deleteIndexByQuery(Query $query)
- {
- $index = $this->connection->getClient()->getIndex($this->indexFactory->getIndexName());
- if (!$index->exists()) {
- $this->logger->notice(
- 'Index did not exist, therefore items can not be deleted by query.',
- [$this->indexFactory->getIndexName(), $query->getQuery()]
- );
- return;
- }
- $response = $index->deleteByQuery($query);
- if ($response->getData()['deleted'] > 0) {
- // Refresh index when delete query is invoked
- $index->refresh();
- }
- }
-
public function search(SearchRequestInterface $searchRequest): SearchResultInterface
{
$this->logger->debug('Search for', [$searchRequest->getSearchTerm()]);
@@ -232,4 +212,22 @@ private function withType(string $documentType, callable $callback)
$callback($type, $documentType);
$type->getIndex()->refresh();
}
+
+ private function deleteDocumentsByQuery(string $documentType, Query $query)
+ {
+ try {
+ $index = $this->indexFactory->getIndex($this->connection, $documentType);
+ $response = $index->deleteByQuery($query);
+
+ if ($response->getData()['deleted'] > 0) {
+ // Refresh index when delete query is invoked
+ $index->refresh();
+ }
+ } catch (\InvalidArgumentException $e) {
+ $this->logger->notice(
+ 'Index did not exist, therefore items can not be deleted by query.',
+ [$documentType, $query->getQuery()]
+ );
+ }
+ }
}
diff --git a/Classes/Connection/Elasticsearch/IndexFactory.php b/Classes/Connection/Elasticsearch/IndexFactory.php
index 2482c0eb..718342fa 100644
--- a/Classes/Connection/Elasticsearch/IndexFactory.php
+++ b/Classes/Connection/Elasticsearch/IndexFactory.php
@@ -70,22 +70,35 @@ public function getIndexName(): string
}
/**
- * Get an index based on TYPO3 table name.
+ * @throws \InvalidArgumentException If index does not exist.
*/
public function getIndex(Connection $connection, string $documentType): \Elastica\Index
{
$index = $connection->getClient()->getIndex($this->getIndexName());
if ($index->exists() === false) {
- $config = $this->getConfigurationFor($documentType);
- $this->logger->debug(sprintf('Create index %s.', $documentType), [$documentType, $config]);
- $index->create($config);
- $this->logger->debug(sprintf('Created index %s.', $documentType), [$documentType]);
+ throw new \InvalidArgumentException('The requested index does not exist.', 1546173102);
}
return $index;
}
+ public function createIndex(Connection $connection, string $documentType): \Elastica\Index
+ {
+ $index = $connection->getClient()->getIndex($this->getIndexName());
+
+ if ($index->exists() === true) {
+ return $index;
+ }
+
+ $config = $this->getConfigurationFor($documentType);
+ $this->logger->debug(sprintf('Create index %s.', $documentType), [$documentType, $config]);
+ $index->create($config);
+ $this->logger->debug(sprintf('Created index %s.', $documentType), [$documentType]);
+
+ return $index;
+ }
+
protected function getConfigurationFor(string $documentType): array
{
try {
diff --git a/Classes/Connection/Elasticsearch/TypeFactory.php b/Classes/Connection/Elasticsearch/TypeFactory.php
index 92cc6a1e..8e52eb25 100644
--- a/Classes/Connection/Elasticsearch/TypeFactory.php
+++ b/Classes/Connection/Elasticsearch/TypeFactory.php
@@ -49,12 +49,9 @@ public function __construct(
$this->connection = $connection;
}
- /**
- * Get an index bases on TYPO3 table name.
- */
public function getType(string $documentType): \Elastica\Type
{
- $index = $this->indexFactory->getIndex($this->connection, $documentType);
+ $index = $this->indexFactory->createIndex($this->connection, $documentType);
return $index->getType('document');
}
}
diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php
index adb172e4..7eae6156 100644
--- a/Classes/Domain/Index/AbstractIndexer.php
+++ b/Classes/Domain/Index/AbstractIndexer.php
@@ -106,14 +106,14 @@ public function indexDocument(string $identifier)
public function delete()
{
$this->logger->info('Start deletion of index.');
- $this->connection->deleteIndex();
+ $this->connection->deleteIndex($this->getDocumentName());
$this->logger->info('Finish deletion.');
}
- public function deleteDocuments()
+ public function deleteAllDocuments()
{
$this->logger->info('Start deletion of indexed documents.');
- $this->connection->deleteIndexByDocumentType($this->getDocumentName());
+ $this->connection->deleteAllDocuments($this->getDocumentName());
$this->logger->info('Finish deletion.');
}
diff --git a/Classes/Domain/Index/IndexerInterface.php b/Classes/Domain/Index/IndexerInterface.php
index f413677d..4071ee85 100644
--- a/Classes/Domain/Index/IndexerInterface.php
+++ b/Classes/Domain/Index/IndexerInterface.php
@@ -42,9 +42,9 @@ public function indexDocument(string $identifier);
public function delete();
/**
- * Delete the whole index.
+ * Delete all documents from index.
*/
- public function deleteDocuments();
+ public function deleteAllDocuments();
/**
* Receives the identifier of the indexer itself.
diff --git a/Documentation/source/changelog/0.1.0.rst b/Documentation/source/changelog/0.1.0.rst
index 036a2222..3cfc4cec 100644
--- a/Documentation/source/changelog/0.1.0.rst
+++ b/Documentation/source/changelog/0.1.0.rst
@@ -8,7 +8,7 @@ v0.1.0
0.1.0/2018-changed-interfaces
0.1.0/2018-elasticsearch-upgrade
0.1.0/2018-search-service-interface
- 0.1.0/20181027-added-flush-command
+ 0.1.0/20181027-added-delete-all-documents-command
0.1.0/20181027-allow-multiple-identifier-on-cli
0.1.0/20181027-remove-cms7-support
0.1.0/20181028-fluid-templating-list-items
diff --git a/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst b/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
index 993b7da8..669c7765 100644
--- a/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
+++ b/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
@@ -5,7 +5,7 @@ Some interfaces and abstract classes have been adjusted:
``Codappix\SearchCore\Connection\ConnectionInterface``:
- * New method ``public function deleteIndexByDocumentType(string $documentType);``
+ * New method ``public function deleteAllDocuments(string $documentType);``
``Codappix\SearchCore\Domain\Index\IndexerInterface``:
@@ -28,4 +28,12 @@ Also some exceptions have changed:
throws an ``\InvalidArgumentException`` instead of ``\Exception``, if no
``search_identifier`` was provided.
+* ``Codappix\SearchCore\Connection\Elasticsearch\IndexFactory::getIndex()`` now
+ throws an ``\InvalidArgumentException`` if the index does not exist. Leaving
+ handling up to the caller.
+ Before the index was created if it didn't exist. To create an index, a new method
+ ``public function createIndex(Connection $connection, string $documentType): \Elastica\Index``
+ was added. This method will only create the index if it didn't exist before.
+ In the end, the index is returned always. Making this method a 1:1 replacement for
+ older ``getIndex()``.
diff --git a/Documentation/source/changelog/0.1.0/20181027-added-delete-all-documents-command.rst b/Documentation/source/changelog/0.1.0/20181027-added-delete-all-documents-command.rst
new file mode 100644
index 00000000..22f221a2
--- /dev/null
+++ b/Documentation/source/changelog/0.1.0/20181027-added-delete-all-documents-command.rst
@@ -0,0 +1,11 @@
+Feature "Added delete documents command"
+========================================
+
+A new command to delete all documents within an index was added. In contrast to the
+existing delete command, this deletes only documents but keeps the index.
+
+E.g. if your backend is Elasticsearch or a relational database, the index or table is
+kept, including structure or mappings, while only the documents or rows are removed.
+
+In contrast the existing delete command will still remove the index or table itself,
+depending on the used connection.
diff --git a/Documentation/source/changelog/0.1.0/20181027-added-flush-command.rst b/Documentation/source/changelog/0.1.0/20181027-added-flush-command.rst
deleted file mode 100644
index 569865d9..00000000
--- a/Documentation/source/changelog/0.1.0/20181027-added-flush-command.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-Feature "Added flush command"
-=============================
-
-A new command to flush indices was added. In contrast to the existing delete command,
-this one will delete the whole index, while the existing delete command only deletes
-all documents within an index.
diff --git a/Documentation/source/usage.rst b/Documentation/source/usage.rst
index 687ae2d0..b385c556 100644
--- a/Documentation/source/usage.rst
+++ b/Documentation/source/usage.rst
@@ -36,18 +36,17 @@ documents from the index.
Multiple indexes can be called by providing a comma separated list of identifiers as
a single argument. Spaces before and after commas are ignored.
-.. _usage_manual_flush:
+.. _usage_manual_delete_all_documents:
-Manual flush
-------------
+Manual delete all documents
+---------------------------
-You can trigger flush for indexes from CLI::
+You can trigger deletion of all documents for indexes from CLI::
- ./typo3/cli_dispatch.phpsh extbase index:flush --identifiers 'pages'
- ./bin/typo3cms index:flush --identifiers 'pages'
+ ./typo3/cli_dispatch.phpsh extbase index:deletedocuments --identifiers 'pages'
+ ./bin/typo3cms index:deletedocuments --identifiers 'pages'
-This will flush the index for the table ``pages``. Flush means removing the index
-from backend.
+This will delete all documents within the index for the table ``pages``.
Multiple indexes can be called by providing a comma separated list of identifiers as
a single argument. Spaces before and after commas are ignored.
diff --git a/Tests/Functional/Connection/Elasticsearch/IndexDeletionTest.php b/Tests/Functional/Connection/Elasticsearch/IndexDeletionTest.php
index ee14f259..ae277378 100644
--- a/Tests/Functional/Connection/Elasticsearch/IndexDeletionTest.php
+++ b/Tests/Functional/Connection/Elasticsearch/IndexDeletionTest.php
@@ -89,14 +89,12 @@ public function documentsAreDeleted()
$response = $this->client->request('typo3content/_search?q=*:*');
$this->assertSame($response->getData()['hits']['total'], 5, 'Not exactly 5 documents are in index.');
- $contentIndexer->deleteDocuments();
+ $contentIndexer->deleteAllDocuments();
$response = $this->client->request('typo3content/_search?q=*:*');
$this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 documents are in index.');
- $pageIndexer->deleteDocuments();
+ $pageIndexer->deleteAllDocuments();
$response = $this->client->request('typo3content/_search?q=*:*');
$this->assertSame($response->getData()['hits']['total'], 0, 'Index should be empty.');
-
- $index->delete();
}
}
diff --git a/Tests/Unit/Command/IndexCommandControllerTest.php b/Tests/Unit/Command/IndexCommandControllerTest.php
index 2b52109b..69f02bab 100644
--- a/Tests/Unit/Command/IndexCommandControllerTest.php
+++ b/Tests/Unit/Command/IndexCommandControllerTest.php
@@ -97,7 +97,7 @@ public function indexerExecutesForAllowedTable()
/**
* @test
*/
- public function deletionIsPossible()
+ public function deletionOfDocumentsIsPossible()
{
$indexerMock = $this->getMockBuilder(TcaIndexer::class)
->disableOriginalConstructor()
@@ -114,14 +114,14 @@ public function deletionIsPossible()
->will($this->returnValue($indexerMock));
$indexerMock->expects($this->once())
- ->method('deleteDocuments');
- $this->subject->deleteCommand('allowedTable');
+ ->method('deleteAllDocuments');
+ $this->subject->deleteDocumentsCommand('allowedTable');
}
/**
* @test
*/
- public function flushIsPossible()
+ public function deletionOfIndexIsPossible()
{
$indexerMock = $this->getMockBuilder(TcaIndexer::class)
->disableOriginalConstructor()
@@ -139,7 +139,7 @@ public function flushIsPossible()
$indexerMock->expects($this->once())
->method('delete');
- $this->subject->flushCommand('pages');
+ $this->subject->deleteCommand('pages');
}
/**
diff --git a/Tests/Unit/Connection/Elasticsearch/IndexFactoryTest.php b/Tests/Unit/Connection/Elasticsearch/IndexFactoryTest.php
index 6d80f704..77d5f900 100644
--- a/Tests/Unit/Connection/Elasticsearch/IndexFactoryTest.php
+++ b/Tests/Unit/Connection/Elasticsearch/IndexFactoryTest.php
@@ -150,6 +150,6 @@ public function typoScriptConfigurationIsProvidedToIndex()
])
);
- $this->subject->getIndex($connection, 'someIndex');
+ $this->subject->createIndex($connection, 'someIndex');
}
}
From 7f2249e3ffbdb643376677b6146b63b998b142c3 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sun, 30 Dec 2018 14:00:22 +0100
Subject: [PATCH 67/73] TASK: Use a single array utility
Instead of only adding a new class for one static method, we extend the
existing class to only import a single class.
This way we extend the original array utility function collection.
---
Classes/Configuration/ConfigurationContainer.php | 2 +-
Classes/Domain/Model/SearchRequest.php | 5 ++---
Classes/Domain/Search/QueryFactory.php | 2 +-
Classes/Domain/Search/SearchService.php | 2 +-
Classes/Utility/ArrayUtility.php | 4 +++-
Documentation/source/development/configuration.rst | 2 +-
6 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/Classes/Configuration/ConfigurationContainer.php b/Classes/Configuration/ConfigurationContainer.php
index b213c9ba..9917f12d 100644
--- a/Classes/Configuration/ConfigurationContainer.php
+++ b/Classes/Configuration/ConfigurationContainer.php
@@ -21,7 +21,7 @@
* 02110-1301, USA.
*/
-use TYPO3\CMS\Core\Utility\ArrayUtility;
+use Codappix\SearchCore\Utility\ArrayUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
/**
diff --git a/Classes/Domain/Model/SearchRequest.php b/Classes/Domain/Model/SearchRequest.php
index 0d8865b1..32efb5da 100644
--- a/Classes/Domain/Model/SearchRequest.php
+++ b/Classes/Domain/Model/SearchRequest.php
@@ -26,8 +26,7 @@
use Codappix\SearchCore\Connection\SearchRequestInterface;
use Codappix\SearchCore\Connection\SearchResultInterface;
use Codappix\SearchCore\Domain\Search\SearchServiceInterface;
-use Codappix\SearchCore\Utility\ArrayUtility as CustomArrayUtility;
-use TYPO3\CMS\Core\Utility\ArrayUtility;
+use Codappix\SearchCore\Utility\ArrayUtility;
/**
* Represents a search request used to process an actual search.
@@ -99,7 +98,7 @@ public function getSearchTerm(): string
public function setFilter(array $filter)
{
$filter = ArrayUtility::removeArrayEntryByValue($filter, '');
- $this->filter = CustomArrayUtility::removeEmptyElementsRecursively($filter);
+ $this->filter = ArrayUtility::removeEmptyElementsRecursively($filter);
}
public function hasFilter(): bool
diff --git a/Classes/Domain/Search/QueryFactory.php b/Classes/Domain/Search/QueryFactory.php
index f34befc9..c7565b14 100644
--- a/Classes/Domain/Search/QueryFactory.php
+++ b/Classes/Domain/Search/QueryFactory.php
@@ -25,7 +25,7 @@
use Codappix\SearchCore\Configuration\ConfigurationUtility;
use Codappix\SearchCore\Configuration\InvalidArgumentException;
use Codappix\SearchCore\Connection\SearchRequestInterface;
-use TYPO3\CMS\Core\Utility\ArrayUtility;
+use Codappix\SearchCore\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
diff --git a/Classes/Domain/Search/SearchService.php b/Classes/Domain/Search/SearchService.php
index fedf09e9..43b54b8c 100644
--- a/Classes/Domain/Search/SearchService.php
+++ b/Classes/Domain/Search/SearchService.php
@@ -29,7 +29,7 @@
use Codappix\SearchCore\DataProcessing\Service as DataProcessorService;
use Codappix\SearchCore\Domain\Model\FacetRequest;
use Codappix\SearchCore\Domain\Model\SearchResult;
-use TYPO3\CMS\Core\Utility\ArrayUtility;
+use Codappix\SearchCore\Utility\ArrayUtility;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
/**
diff --git a/Classes/Utility/ArrayUtility.php b/Classes/Utility/ArrayUtility.php
index 91e9e47c..29815b15 100644
--- a/Classes/Utility/ArrayUtility.php
+++ b/Classes/Utility/ArrayUtility.php
@@ -21,7 +21,9 @@
* 02110-1301, USA.
*/
-class ArrayUtility
+use TYPO3\CMS\Core\Utility\ArrayUtility as Typo3ArrayUtility;
+
+class ArrayUtility extends Typo3ArrayUtility
{
/**
* Recursively removes empty array elements.
diff --git a/Documentation/source/development/configuration.rst b/Documentation/source/development/configuration.rst
index ba976c70..e9827ff8 100644
--- a/Documentation/source/development/configuration.rst
+++ b/Documentation/source/development/configuration.rst
@@ -25,7 +25,7 @@ SearchCoreConfigurationContainer.php::
use Codappix\SearchCore\Configuration\ConfigurationContainer;
use Codappix\SearchCore\Configuration\NoConfigurationException;
- use TYPO3\CMS\Core\Utility\ArrayUtility;
+ use Codappix\SearchCore\Utility\ArrayUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
/**
From 09cbaede293d3d9cef4c9f7a15a55f8bbb3a2e4e Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sun, 30 Dec 2018 14:01:10 +0100
Subject: [PATCH 68/73] TASK: Remove unused code
E.g. use statement and injected object manager.
---
Classes/Domain/Index/TcaIndexer/PagesIndexer.php | 11 +----------
Classes/Domain/Model/SearchRequest.php | 1 -
2 files changed, 1 insertion(+), 11 deletions(-)
diff --git a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
index 5c1bca47..c2464c63 100644
--- a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
+++ b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
@@ -26,19 +26,12 @@
use Codappix\SearchCore\Domain\Index\TcaIndexer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\RootlineUtility;
-use TYPO3\CMS\Extbase\Object\ObjectManager;
-use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
/**
* Specific indexer for Pages, will basically add content of page.
*/
class PagesIndexer extends TcaIndexer
{
- /**
- * @var ObjectManagerInterface
- */
- protected $objectManager;
-
/**
* @var TcaTableServiceInterface
*/
@@ -54,12 +47,10 @@ public function __construct(
TcaTableServiceInterface $tcaTableService,
TcaTableServiceInterface $contentTableService,
ConnectionInterface $connection,
- ConfigurationContainerInterface $configuration,
- ObjectManagerInterface $objectManager
+ ConfigurationContainerInterface $configuration
) {
parent::__construct($tcaTableService, $connection, $configuration);
$this->contentTableService = $contentTableService;
- $this->objectManager = $objectManager;
}
protected function prepareRecord(array &$record)
diff --git a/Classes/Domain/Model/SearchRequest.php b/Classes/Domain/Model/SearchRequest.php
index 32efb5da..29756d0e 100644
--- a/Classes/Domain/Model/SearchRequest.php
+++ b/Classes/Domain/Model/SearchRequest.php
@@ -24,7 +24,6 @@
use Codappix\SearchCore\Connection\ConnectionInterface;
use Codappix\SearchCore\Connection\FacetRequestInterface;
use Codappix\SearchCore\Connection\SearchRequestInterface;
-use Codappix\SearchCore\Connection\SearchResultInterface;
use Codappix\SearchCore\Domain\Search\SearchServiceInterface;
use Codappix\SearchCore\Utility\ArrayUtility;
From 1efb06d84b78df2844d144b8c1060d3df2cb9b5a Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sun, 30 Dec 2018 14:01:38 +0100
Subject: [PATCH 69/73] TASK: Remove wrong phpdoc
---
Classes/Domain/Model/QueryResultInterfaceStub.php | 3 ---
1 file changed, 3 deletions(-)
diff --git a/Classes/Domain/Model/QueryResultInterfaceStub.php b/Classes/Domain/Model/QueryResultInterfaceStub.php
index c7af6be7..6cd6f4fe 100644
--- a/Classes/Domain/Model/QueryResultInterfaceStub.php
+++ b/Classes/Domain/Model/QueryResultInterfaceStub.php
@@ -45,9 +45,6 @@ public function toArray()
throw new \BadMethodCallException('Method is not implemented yet.', 1502195135);
}
- /**
- * @throws \BadMethodCallException
- */
public function offsetExists($offset)
{
// Return false to allow Fluid to use appropriate getter methods.
From a6f7f31274975dcefe2d07f9137cef896f882367 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sun, 30 Dec 2018 14:01:45 +0100
Subject: [PATCH 70/73] TASK: Do not publish internal method
---
Classes/Domain/Index/AbstractIndexer.php | 2 +-
Classes/Domain/Index/TcaIndexer.php | 2 +-
.../source/changelog/0.1.0/2018-changed-interfaces.rst | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php
index 7eae6156..0172c12c 100644
--- a/Classes/Domain/Index/AbstractIndexer.php
+++ b/Classes/Domain/Index/AbstractIndexer.php
@@ -208,5 +208,5 @@ abstract protected function getRecord(int $identifier): array;
abstract protected function getDocumentName(): string;
- abstract public function getDocumentIdentifier($identifier): string;
+ abstract protected function getDocumentIdentifier($identifier): string;
}
diff --git a/Classes/Domain/Index/TcaIndexer.php b/Classes/Domain/Index/TcaIndexer.php
index e1b03b75..0c1d00d0 100644
--- a/Classes/Domain/Index/TcaIndexer.php
+++ b/Classes/Domain/Index/TcaIndexer.php
@@ -89,7 +89,7 @@ protected function getDocumentName(): string
return $this->tcaTableService->getTableName();
}
- public function getDocumentIdentifier($identifier): string
+ protected function getDocumentIdentifier($identifier): string
{
return $this->getDocumentName() . '-' . $identifier;
}
diff --git a/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst b/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
index 669c7765..93d5c813 100644
--- a/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
+++ b/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
@@ -15,7 +15,7 @@ Some interfaces and abstract classes have been adjusted:
``Codappix\SearchCore\Domain\Index\AbstractIndexer``:
- * New method ``abstract public function getDocumentIdentifier($identifier): string;``
+ * New method ``abstract protected function getDocumentIdentifier($identifier): string;``
``Codappix\SearchCore\Connection\SearchRequestInterface``:
From 4c99009ea0aed618f776c92325ac9ea9dee04c40 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sun, 30 Dec 2018 14:45:16 +0100
Subject: [PATCH 71/73] TASK: Remove cache implementation
As it does not use TYPO3 caching framework but custom feature.
---
Classes/Domain/Search/CachedSearchService.php | 69 -------------------
.../0.1.0/2018-changed-interfaces.rst | 4 +-
.../Unit/Controller/SearchControllerTest.php | 4 +-
ext_localconf.php | 8 +--
4 files changed, 7 insertions(+), 78 deletions(-)
delete mode 100644 Classes/Domain/Search/CachedSearchService.php
diff --git a/Classes/Domain/Search/CachedSearchService.php b/Classes/Domain/Search/CachedSearchService.php
deleted file mode 100644
index a8655f3c..00000000
--- a/Classes/Domain/Search/CachedSearchService.php
+++ /dev/null
@@ -1,69 +0,0 @@
-
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-use Codappix\SearchCore\Connection\SearchRequestInterface;
-use Codappix\SearchCore\Connection\SearchResultInterface;
-use TYPO3\CMS\Core\SingletonInterface;
-
-/**
- * Service to process a search request, only once per request.
- */
-class CachedSearchService implements SingletonInterface, SearchServiceInterface
-{
- /**
- * @var array
- */
- protected $results = [];
-
- /**
- * @var SearchService
- */
- protected $searchService;
-
- public function __construct(SearchService $searchService)
- {
- $this->searchService = $searchService;
- }
-
- public function search(SearchRequestInterface $searchRequest): SearchResultInterface
- {
- $hash = $this->getHash($searchRequest);
- if (isset($this->results[$hash]) && $this->results[$hash] instanceof SearchResultInterface) {
- return $this->results[$hash];
- }
- return $this->results[$hash] = $this->searchService->search($searchRequest);
- }
-
- public function processResult(SearchResultInterface $searchResult): SearchResultInterface
- {
- return $this->searchService->processResult($searchResult);
- }
-
- protected function getHash(SearchRequestInterface $searchRequest): string
- {
- if (is_callable([$searchRequest, 'getRequestHash'])) {
- return (string)$searchRequest->getRequestHash();
- }
- return sha1(serialize($searchRequest));
- }
-}
diff --git a/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst b/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
index 93d5c813..740acb35 100644
--- a/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
+++ b/Documentation/source/changelog/0.1.0/2018-changed-interfaces.rst
@@ -25,8 +25,8 @@ Some interfaces and abstract classes have been adjusted:
Also some exceptions have changed:
* ``Codappix\SearchCore\Connection\Elasticsearch\DocumentFactory::getDocument()`` now
-throws an ``\InvalidArgumentException`` instead of ``\Exception``, if no
-``search_identifier`` was provided.
+ throws an ``\InvalidArgumentException`` instead of ``\Exception``, if no
+ ``search_identifier`` was provided.
* ``Codappix\SearchCore\Connection\Elasticsearch\IndexFactory::getIndex()`` now
throws an ``\InvalidArgumentException`` if the index does not exist. Leaving
diff --git a/Tests/Unit/Controller/SearchControllerTest.php b/Tests/Unit/Controller/SearchControllerTest.php
index 0357b868..6c9fed64 100644
--- a/Tests/Unit/Controller/SearchControllerTest.php
+++ b/Tests/Unit/Controller/SearchControllerTest.php
@@ -23,7 +23,7 @@
use Codappix\SearchCore\Controller\SearchController;
use Codappix\SearchCore\Domain\Model\SearchRequest;
-use Codappix\SearchCore\Domain\Search\CachedSearchService;
+use Codappix\SearchCore\Domain\Search\SearchService;
use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase;
use TYPO3\CMS\Extbase\Mvc\Web\Request;
use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -55,7 +55,7 @@ public function setUp()
parent::setUp();
- $searchService = $this->getMockBuilder(CachedSearchService::class)
+ $searchService = $this->getMockBuilder(SearchService::class)
->disableOriginalConstructor()
->getMock();
$this->request = new Request();
diff --git a/ext_localconf.php b/ext_localconf.php
index 0941be32..f400aa55 100644
--- a/ext_localconf.php
+++ b/ext_localconf.php
@@ -58,14 +58,12 @@
(isset($configuration['disable.']['elasticsearch']) &&
filter_var($configuration['disable.']['elasticsearch'], FILTER_VALIDATE_BOOLEAN) === false)
) {
- $container = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class);
+ $container = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+ \TYPO3\CMS\Extbase\Object\Container\Container::class
+ );
$container->registerImplementation(
\Codappix\SearchCore\Connection\ConnectionInterface::class,
\Codappix\SearchCore\Connection\Elasticsearch::class
);
- $container->registerImplementation(
- \Codappix\SearchCore\Domain\Search\SearchServiceInterface::class,
- \Codappix\SearchCore\Domain\Search\CachedSearchService::class
- );
}
})($_EXTKEY, $_EXTCONF);
From f955a9b70a8842c3808c5f92a45bc937abefdf0e Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sun, 30 Dec 2018 14:48:17 +0100
Subject: [PATCH 72/73] FEATURE: Provide basic caching
---
Classes/Domain/Model/SearchRequest.php | 14 ++++++++++++
Classes/Domain/Search/SearchService.php | 22 +++++++++++++++++--
Documentation/source/changelog/0.1.0.rst | 1 +
.../changelog/0.1.0/2018-added-caching.rst | 22 +++++++++++++++++++
Documentation/source/conf.py | 1 +
.../Unit/Domain/Search/SearchServiceTest.php | 12 +++++++++-
ext_localconf.php | 8 +++++++
7 files changed, 77 insertions(+), 3 deletions(-)
create mode 100644 Documentation/source/changelog/0.1.0/2018-added-caching.rst
diff --git a/Classes/Domain/Model/SearchRequest.php b/Classes/Domain/Model/SearchRequest.php
index 29756d0e..183463e0 100644
--- a/Classes/Domain/Model/SearchRequest.php
+++ b/Classes/Domain/Model/SearchRequest.php
@@ -188,6 +188,20 @@ public function getOffset()
return $this->offset;
}
+ /**
+ * Used, e.g. by caching to determine identifier.
+ */
+ public function __sleep()
+ {
+ return [
+ 'query',
+ 'filter',
+ 'facets',
+ 'offset',
+ 'limit',
+ ];
+ }
+
/**
* @throws \BadMethodCallException
*/
diff --git a/Classes/Domain/Search/SearchService.php b/Classes/Domain/Search/SearchService.php
index 43b54b8c..e5b81d58 100644
--- a/Classes/Domain/Search/SearchService.php
+++ b/Classes/Domain/Search/SearchService.php
@@ -30,6 +30,8 @@
use Codappix\SearchCore\Domain\Model\FacetRequest;
use Codappix\SearchCore\Domain\Model\SearchResult;
use Codappix\SearchCore\Utility\ArrayUtility;
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
/**
@@ -57,22 +59,30 @@ class SearchService implements SearchServiceInterface
*/
protected $dataProcessorService;
+ /**
+ * @var FrontendInterface
+ */
+ protected $cache;
+
/**
* @param ConnectionInterface $connection
* @param ConfigurationContainerInterface $configuration
* @param ObjectManagerInterface $objectManager
* @param DataProcessorService $dataProcessorService
+ * @param CacheManager $cacheManager
*/
public function __construct(
ConnectionInterface $connection,
ConfigurationContainerInterface $configuration,
ObjectManagerInterface $objectManager,
- DataProcessorService $dataProcessorService
+ DataProcessorService $dataProcessorService,
+ CacheManager $cacheManager
) {
$this->connection = $connection;
$this->configuration = $configuration;
$this->objectManager = $objectManager;
$this->dataProcessorService = $dataProcessorService;
+ $this->cache = $cacheManager->getCache('search_core');
}
public function search(SearchRequestInterface $searchRequest): SearchResultInterface
@@ -85,7 +95,15 @@ public function search(SearchRequestInterface $searchRequest): SearchResultInter
$searchRequest->setConnection($this->connection);
$searchRequest->setSearchService($this);
- return $this->processResult($this->connection->search($searchRequest));
+ $identifier = sha1('search' . serialize($searchRequest));
+ if ($this->cache->has($identifier)) {
+ return $this->cache->get($identifier);
+ }
+
+ $result = $this->processResult($this->connection->search($searchRequest));
+ $this->cache->set($identifier, $result);
+
+ return $result;
}
/**
diff --git a/Documentation/source/changelog/0.1.0.rst b/Documentation/source/changelog/0.1.0.rst
index 3cfc4cec..bcd0cd68 100644
--- a/Documentation/source/changelog/0.1.0.rst
+++ b/Documentation/source/changelog/0.1.0.rst
@@ -4,6 +4,7 @@ v0.1.0
.. toctree::
:maxdepth: 1
+ 0.1.0/2018-added-caching
0.1.0/2018-added-content-element-wizard
0.1.0/2018-changed-interfaces
0.1.0/2018-elasticsearch-upgrade
diff --git a/Documentation/source/changelog/0.1.0/2018-added-caching.rst b/Documentation/source/changelog/0.1.0/2018-added-caching.rst
new file mode 100644
index 00000000..bca0fe42
--- /dev/null
+++ b/Documentation/source/changelog/0.1.0/2018-added-caching.rst
@@ -0,0 +1,22 @@
+Feature "Added caching"
+=======================
+
+Processing searches are now cacheable, the TYPO3 caching framework is used for
+caching. By default the ``NullBackend`` is used to keep old behaviour, which matches
+searches the best.
+
+Still if the same search is run multiple times during a single request, the
+``TransientMemoryBackend`` is a nice option.
+
+Depending on search backend, one might also use a different backend for caching and
+configure some TTL.
+
+.. note::
+
+ Paging is currently not supported for caching.
+
+ Using ``NullBackend`` or ``TransientMemoryBackend`` will work, but using persistent
+ backends in combination with fluid pagination widget will lead to errors right
+ now.
+
+For further information, check out official :ref:`t3explained:caching` documentation.
diff --git a/Documentation/source/conf.py b/Documentation/source/conf.py
index c559ba33..f339f20a 100644
--- a/Documentation/source/conf.py
+++ b/Documentation/source/conf.py
@@ -304,6 +304,7 @@
intersphinx_mapping = {
't3tcaref': ('https://docs.typo3.org/typo3cms/TCAReference/', None),
't3tsref': ('https://docs.typo3.org/typo3cms/TyposcriptReference/', None),
+ 't3explained': ('https://docs.typo3.org/typo3cms/CoreApiReference/', None),
}
extlinks = {
'project': ('https://github.com/Codappix/search_core/projects/%s', 'Github project: '),
diff --git a/Tests/Unit/Domain/Search/SearchServiceTest.php b/Tests/Unit/Domain/Search/SearchServiceTest.php
index 3a6bff81..49e821d0 100644
--- a/Tests/Unit/Domain/Search/SearchServiceTest.php
+++ b/Tests/Unit/Domain/Search/SearchServiceTest.php
@@ -30,6 +30,8 @@
use Codappix\SearchCore\Domain\Model\SearchResult;
use Codappix\SearchCore\Domain\Search\SearchService;
use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase;
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
class SearchServiceTest extends AbstractUnitTestCase
@@ -68,6 +70,13 @@ public function setUp()
{
parent::setUp();
+ $cacheMock = $this->getMockBuilder(FrontendInterface::class)->getMock();
+ $cacheManagerMock = $this->getMockBuilder(CacheManager::class)->getMock();
+ $cacheManagerMock->expects($this->any())
+ ->method('getCache')
+ ->with('search_core')
+ ->willReturn($cacheMock);
+
$this->result = $this->getMockBuilder(SearchResultInterface::class)
->disableOriginalConstructor()
->getMock();
@@ -88,7 +97,8 @@ public function setUp()
$this->connection,
$this->configuration,
$this->objectManager,
- $this->dataProcessorService
+ $this->dataProcessorService,
+ $cacheManagerMock
);
}
diff --git a/ext_localconf.php b/ext_localconf.php
index f400aa55..2934bc4e 100644
--- a/ext_localconf.php
+++ b/ext_localconf.php
@@ -54,6 +54,14 @@
''
);
+ if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['search_core'])) {
+ $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['search_core'] = [];
+ }
+ if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['search_core']['backend'])) {
+ $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['search_core']['backend'] =
+ \TYPO3\CMS\Core\Cache\Backend\NullBackend::class;
+ }
+
if (empty($configuration) ||
(isset($configuration['disable.']['elasticsearch']) &&
filter_var($configuration['disable.']['elasticsearch'], FILTER_VALIDATE_BOOLEAN) === false)
From 73d61bd7d4812d4ba5a94c8356ad56656972ca77 Mon Sep 17 00:00:00 2001
From: Daniel Siepmann
Date: Sun, 30 Dec 2018 15:03:10 +0100
Subject: [PATCH 73/73] FEATURE: Provide more information about concept
---
Documentation/source/concepts.rst | 10 +++++++++-
Documentation/source/features.rst | 10 ++++++++++
Documentation/source/readme.rst | 30 ++++++++++++++++++------------
3 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/Documentation/source/concepts.rst b/Documentation/source/concepts.rst
index f81121b5..d203f878 100644
--- a/Documentation/source/concepts.rst
+++ b/Documentation/source/concepts.rst
@@ -4,7 +4,8 @@ Concepts
========
The main concept is to provide a foundation where other developers can profit from, to provide
-integrations into search services like Elasticsearch, Algolia, ... .
+integrations into search services like Elasticsearch, Algolia, …. But also to provide
+an ETL Framework.
Our code contains the following concepts which should be understand:
@@ -18,6 +19,9 @@ interfaces. The main purpose is to provide a stable API between TYPO3 and concre
For information about implementing a new connection, take a look at :ref:`development_connection`.
+These are equivalent to "Load" of ETL while "indexing", and equivalent to
+"Extraction" in frontend mode.
+
.. _concepts_indexing:
Indexing
@@ -31,6 +35,8 @@ Currently :ref:`TcaIndexer` and :ref:`PagesIndexer` are provided.
For information about implementing a new indexer, take a look at :ref:`development_indexer`.
+This is the process of "loading" data inside the ETL.
+
.. _concepts_dataprocessing:
DataProcessing
@@ -47,3 +53,5 @@ flexible as integrators are able to configure DataProcessors and change their or
Configuration is done through TypoScript, see :ref:`dataprocessors`.
For information about implementing a new DataProcessor, take a look at :ref:`development_dataprocessor`.
+
+This is the "transforming" step of ETL.
diff --git a/Documentation/source/features.rst b/Documentation/source/features.rst
index 57014bdf..1cb5a660 100644
--- a/Documentation/source/features.rst
+++ b/Documentation/source/features.rst
@@ -46,6 +46,16 @@ output.
See :ref:`concepts_dataprocessing` in :ref:`concepts` section.
+.. _feature_up_to_you:
+
+Up to you
+---------
+
+The following is not provided by default, but possible with custom PHP code:
+
+* Integrating Social Media Feed imports via custom indexer to display feed content
+ inside of TYPO3 or publishing via custom connections.
+
.. _features_planned:
Planned
diff --git a/Documentation/source/readme.rst b/Documentation/source/readme.rst
index f4ad9179..6f26c433 100644
--- a/Documentation/source/readme.rst
+++ b/Documentation/source/readme.rst
@@ -7,22 +7,28 @@ Introduction
What does it do?
----------------
-The goal of this extension is to provide search integrations into TYPO3 CMS. The extension will
-provide a convenient API to allow developers to provide concrete implementations of backends like
-Elasticsearch, Algolia or Solr.
+Contrary to most search solutions, search_core is an ETL (=Extract, Transform, Load)
+Framework. This allows to extract data from one source, transform it, and load them
+into an target system. Focusing on search solutions, but not limited to them.
-The extension provides integration into TYPO3 like a frontend plugin for searches and hooks to
-update search indexes on updates. Also a command line interface is provided for interactions like
-re-indexing.
+The provided process is to extract data from TYPO3 database storage using TCA, to
+transform those data using data processors, and to load them into some search
+storage like Elasticsearch. This is done via Hooks and CLI.
+
+Also the process is to extract data from some storage like Elasticsearch, transform
+the data using data processors and to load them into the TYPO3 frontend. This is done
+via a Frontend Plugin.
Current state
-------------
-This is still a very early beta version. More information can be taken from Github at
-`current issues`_.
+The basic necessary features are already implemented. Still features like workspaces
+or multi language are not provided out of the box.
-We are also focusing on Code Quality and Testing through `travis ci`_, ``phpcs``, ``phpunit`` and
-``phpstan``.
+Also only Elasticsearch is provided out of the box as a storage backend. But an
+implementation for Algolia is already available via 3rd Party:
+https://github.com/martinhummer/search_algolia
-.. _current issues: https://github.com/Codappix/search_core/issues
-.. _travis ci: https://travis-ci.org/Codappix/search_core
+As the initial intend was to provide a common API and implementation for arbitrary
+search implementations for TYPO3, the API is not fully implemented for ETL right now.
+Also that's the reason for using "search_core" as extension name.