mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 10:16:10 +01:00
FEATURE: Split configuration to support the concepts
* Add a further level in configurations to support multiple connections and indexer. Relates: #31
This commit is contained in:
parent
8441dcdff2
commit
5989b65ae0
13 changed files with 110 additions and 76 deletions
|
@ -57,7 +57,7 @@ class IndexCommandController extends CommandController
|
||||||
{
|
{
|
||||||
// TODO: Allow to index multiple tables at once?
|
// TODO: Allow to index multiple tables at once?
|
||||||
// TODO: Also allow to index everything?
|
// TODO: Also allow to index everything?
|
||||||
if (! in_array($table, GeneralUtility::trimExplode(',', $this->configuration->get('index', 'allowedTables')))) {
|
if (! in_array($table, GeneralUtility::trimExplode(',', $this->configuration->get('indexer.tca.allowedTables')))) {
|
||||||
$this->outputLine('Table is not allowed for indexing.');
|
$this->outputLine('Table is not allowed for indexing.');
|
||||||
$this->quit(1);
|
$this->quit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace Leonmrni\SearchCore\Configuration;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||||
|
use TYPO3\CMS\Extbase\Utility\ArrayUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container of all configurations for extension.
|
* Container of all configurations for extension.
|
||||||
|
@ -29,14 +30,14 @@ use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||||
class ConfigurationContainer implements ConfigurationContainerInterface
|
class ConfigurationContainer implements ConfigurationContainerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Plaint TypoScript array from extbase for extension / plugin.
|
* Plain TypoScript array from extbase for extension / plugin.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $settings;
|
protected $settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject news settings via ConfigurationManager.
|
* Inject settings via ConfigurationManager.
|
||||||
*
|
*
|
||||||
* @param ConfigurationManagerInterface $configurationManager
|
* @param ConfigurationManagerInterface $configurationManager
|
||||||
*/
|
*/
|
||||||
|
@ -50,34 +51,30 @@ class ConfigurationContainer implements ConfigurationContainerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $section
|
* @param string $path In dot notation.
|
||||||
* @param string $key
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function get($section, $key)
|
public function get($path)
|
||||||
{
|
{
|
||||||
if (!isset($this->settings[$section]) || !isset($this->settings[$section][$key])) {
|
$value = ArrayUtility::getValueByPath($this->settings, $path);
|
||||||
|
|
||||||
|
if ($value === null) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
'The given configuration option does not exist.',
|
'The given configuration option "' . $path . '" does not exist.',
|
||||||
InvalidArgumentException::OPTION_DOES_NOT_EXIST
|
InvalidArgumentException::OPTION_DOES_NOT_EXIST
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->settings[$section][$key];
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $section
|
* @param string $path In dot notation.
|
||||||
* @param string $key
|
* @return mixed
|
||||||
* @return mixed|null
|
|
||||||
*/
|
*/
|
||||||
public function getIfExists($section, $key)
|
public function getIfExists($path)
|
||||||
{
|
{
|
||||||
try {
|
return ArrayUtility::getValueByPath($this->settings, $path);
|
||||||
return $this->get($section, $key);
|
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,20 +30,18 @@ interface ConfigurationContainerInterface extends Singleton
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns the option defined by section and key.
|
* Returns the option defined by section and key.
|
||||||
* May throw an exception if it's not set.
|
* May throw an exception if it's not set or is null.
|
||||||
*
|
*
|
||||||
* @param string $section
|
* @param string $path In dot notation. E.g. indexer.tca.allowedTables
|
||||||
* @param string $key
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get($section, $key);
|
public function get($path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as get but will not throw an exception but return null.
|
* Same as get but will not throw an exception but return null.
|
||||||
*
|
*
|
||||||
* @param string $section
|
* @param string $path In dot notation.
|
||||||
* @param string $key
|
|
||||||
* @return mixed|null
|
* @return mixed|null
|
||||||
*/
|
*/
|
||||||
public function getIfExists($section, $key);
|
public function getIfExists($path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,8 @@ class Connection implements Singleton
|
||||||
$this->elasticaClient = $elasticaClient;
|
$this->elasticaClient = $elasticaClient;
|
||||||
if ($this->elasticaClient === null) {
|
if ($this->elasticaClient === null) {
|
||||||
$this->elasticaClient = new \Elastica\Client([
|
$this->elasticaClient = new \Elastica\Client([
|
||||||
'host' => $this->configuration->get('connection', 'host'),
|
'host' => $this->configuration->get('connections.elasticsearch.host'),
|
||||||
'port' => $this->configuration->get('connection', 'port'),
|
'port' => $this->configuration->get('connections.elasticsearch.port'),
|
||||||
// TODO: Make configurable
|
// TODO: Make configurable
|
||||||
// 'log' => 'file',
|
// 'log' => 'file',
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -151,7 +151,7 @@ class TcaTableService
|
||||||
. ' AND pages.no_search = 0'
|
. ' AND pages.no_search = 0'
|
||||||
;
|
;
|
||||||
|
|
||||||
$userDefinedWhere = $this->configuration->getIfExists('index', $this->tableName);
|
$userDefinedWhere = $this->configuration->getIfExists('indexer.tca.' . $this->tableName);
|
||||||
if (is_string($userDefinedWhere)) {
|
if (is_string($userDefinedWhere)) {
|
||||||
$whereClause .= $userDefinedWhere;
|
$whereClause .= $userDefinedWhere;
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ class TcaTableService
|
||||||
*/
|
*/
|
||||||
protected function isBlackListedRootLineConfigured()
|
protected function isBlackListedRootLineConfigured()
|
||||||
{
|
{
|
||||||
return (bool) $this->configuration->getIfExists('index', 'rootLineBlacklist');
|
return (bool) $this->configuration->getIfExists('indexer.tca.rootLineBlacklist');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,6 +273,6 @@ class TcaTableService
|
||||||
*/
|
*/
|
||||||
protected function getBlackListedRootLine()
|
protected function getBlackListedRootLine()
|
||||||
{
|
{
|
||||||
return GeneralUtility::intExplode(',', $this->configuration->getIfExists('index', 'rootLineBlacklist'));
|
return GeneralUtility::intExplode(',', $this->configuration->getIfExists('indexer.tca.rootLineBlacklist'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ class DataHandler implements Singleton
|
||||||
*/
|
*/
|
||||||
public function getAllowedTablesForIndexing()
|
public function getAllowedTablesForIndexing()
|
||||||
{
|
{
|
||||||
return GeneralUtility::trimExplode(',', $this->configuration->get('index', 'allowedTables'));
|
return GeneralUtility::trimExplode(',', $this->configuration->get('indexer.tca.allowedTables'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
plugin {
|
plugin {
|
||||||
tx_searchcore {
|
tx_searchcore {
|
||||||
settings {
|
settings {
|
||||||
connection {
|
connections {
|
||||||
host = localhost
|
elasticsearch {
|
||||||
port = 9200
|
host = localhost
|
||||||
|
port = 9200
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
index {
|
indexer {
|
||||||
# Pages are not supported yet, see
|
tca {
|
||||||
# https://github.com/DanielSiepmann/search_core/issues/24 but
|
# Pages are not supported yet, see
|
||||||
# should also be added, together with additionalWhereClause
|
# https://github.com/DanielSiepmann/search_core/issues/24 but
|
||||||
# based on doktypes
|
# should also be added, together with additionalWhereClause
|
||||||
allowedTables = tt_content
|
# based on doktypes
|
||||||
|
allowedTables = tt_content
|
||||||
|
|
||||||
tt_content {
|
tt_content {
|
||||||
additionalWhereClause = tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu')
|
additionalWhereClause = tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,35 +34,36 @@ Here is the example default configuration that's provided through static setup:
|
||||||
Options
|
Options
|
||||||
-------
|
-------
|
||||||
|
|
||||||
The following section contain the different options for e.g.
|
The following section contains the different options, e.g. for :ref:`connections` and
|
||||||
``plugin.tx_searchcore.settings.connection`` or ``plugin.tx_searchcore.settings.index``.
|
:ref:`indexer`: ``plugin.tx_searchcore.settings.connection`` or
|
||||||
|
``plugin.tx_searchcore.settings.index``.
|
||||||
.. warning::
|
|
||||||
|
|
||||||
The structure will change as we need to support multiple indexer and connections.
|
|
||||||
The options will stay the same.
|
|
||||||
|
|
||||||
For further information take a look at :issue:`31`.
|
|
||||||
|
|
||||||
.. _configuration_options_connection:
|
.. _configuration_options_connection:
|
||||||
|
|
||||||
connection
|
connections
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^^
|
||||||
|
|
||||||
Holds settings regarding the connection to search service like Elasticsearch or Solr.
|
Holds settings regarding the different possible connections for search services like Elasticsearch
|
||||||
|
or Solr.
|
||||||
|
|
||||||
Configured as::
|
Configured as::
|
||||||
|
|
||||||
plugin {
|
plugin {
|
||||||
tx_searchcore {
|
tx_searchcore {
|
||||||
settings {
|
settings {
|
||||||
connection {
|
connections {
|
||||||
// the settings
|
connectionName {
|
||||||
|
// the settings
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Where ``connectionName`` is one of the available :ref:`connections`.
|
||||||
|
|
||||||
|
The following settings are available. For each setting its documented which connection consumes it.
|
||||||
|
|
||||||
.. _host:
|
.. _host:
|
||||||
|
|
||||||
``host``
|
``host``
|
||||||
|
@ -75,7 +76,7 @@ Configured as::
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
plugin.tx_searchcore.settings.connection.host = localhost
|
plugin.tx_searchcore.settings.connections.elasticsearch.host = localhost
|
||||||
|
|
||||||
.. _port:
|
.. _port:
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ Configured as::
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
plugin.tx_searchcore.settings.connection.port = 9200
|
plugin.tx_searchcore.settings.connections.elasticsearch.port = 9200
|
||||||
|
|
||||||
|
|
||||||
.. _configuration_options_index:
|
.. _configuration_options_index:
|
||||||
|
@ -96,20 +97,26 @@ Configured as::
|
||||||
index
|
index
|
||||||
^^^^^
|
^^^^^
|
||||||
|
|
||||||
Holds settings regarding the indexing of TYPO3 records to search service.
|
Holds settings regarding the indexing, e.g. of TYPO3 records, to search services.
|
||||||
|
|
||||||
Configured as::
|
Configured as::
|
||||||
|
|
||||||
plugin {
|
plugin {
|
||||||
tx_searchcore {
|
tx_searchcore {
|
||||||
settings {
|
settings {
|
||||||
index {
|
indexer {
|
||||||
// the settings
|
indexerName {
|
||||||
|
// the settings
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Where ``indexerName`` is one of the available :ref:`indexer`.
|
||||||
|
|
||||||
|
The following settings are available. For each setting its documented which indexer consumes it.
|
||||||
|
|
||||||
.. _allowedTables:
|
.. _allowedTables:
|
||||||
|
|
||||||
``allowedTables``
|
``allowedTables``
|
||||||
|
@ -124,7 +131,7 @@ Configured as::
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
plugin.tx_searchcore.settings.index.allowedTables = tt_content, fe_users
|
plugin.tx_searchcore.settings.indexer.tca.allowedTables = tt_content, fe_users
|
||||||
|
|
||||||
.. _rootLineBlacklist:
|
.. _rootLineBlacklist:
|
||||||
|
|
||||||
|
@ -142,7 +149,7 @@ Configured as::
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
plugin.tx_searchcore.settings.index.rootLineBlacklist = 3, 10, 100
|
plugin.tx_searchcore.settings.index.tca.rootLineBlacklist = 3, 10, 100
|
||||||
|
|
||||||
Also it's possible to define some behaviour for the different document types. In context of TYPO3
|
Also it's possible to define some behaviour for the different document types. In context of TYPO3
|
||||||
tables are used as document types 1:1. It's possible to configure different tables. The following
|
tables are used as document types 1:1. It's possible to configure different tables. The following
|
||||||
|
@ -161,7 +168,7 @@ options are available:
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
plugin.tx_searchcore.settings.index.tt_content.additionalWhereClause = tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu')
|
plugin.tx_searchcore.settings.index.tca.tt_content.additionalWhereClause = tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu')
|
||||||
|
|
||||||
.. attention::
|
.. attention::
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. highlight:: bash
|
||||||
|
|
||||||
.. _contribution:
|
.. _contribution:
|
||||||
|
|
||||||
Contribution
|
Contribution
|
||||||
|
@ -7,6 +9,22 @@ Everyone is welcome to contribute, whether it's code, issues, feature requests o
|
||||||
|
|
||||||
Below is a documentation what to respect during contributions.
|
Below is a documentation what to respect during contributions.
|
||||||
|
|
||||||
|
.. _contribution_setup:
|
||||||
|
|
||||||
|
Setup
|
||||||
|
-----
|
||||||
|
|
||||||
|
To start contributions regarding code, make sure to setup your system::
|
||||||
|
|
||||||
|
git clone git@github.com:DanielSiepmann/search_core.git \
|
||||||
|
&& cd search_core \
|
||||||
|
&& make install \
|
||||||
|
&& make functionalTests
|
||||||
|
|
||||||
|
If all tests are okay, start your work.
|
||||||
|
|
||||||
|
Of course you might need some requirements like running elasticsearch and composer to work before.
|
||||||
|
|
||||||
.. _contribution_development:
|
.. _contribution_development:
|
||||||
|
|
||||||
Development
|
Development
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
plugin {
|
plugin {
|
||||||
tx_searchcore {
|
tx_searchcore {
|
||||||
settings {
|
settings {
|
||||||
connection {
|
connections {
|
||||||
host = localhost
|
elasticsearch {
|
||||||
port = 9200
|
host = localhost
|
||||||
|
port = 9200
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
index {
|
indexer {
|
||||||
allowedTables = tt_content
|
tca {
|
||||||
|
allowedTables = tt_content
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
plugin {
|
plugin {
|
||||||
tx_searchcore {
|
tx_searchcore {
|
||||||
settings {
|
settings {
|
||||||
index {
|
indexer {
|
||||||
allowedTables = tt_content, fe_user
|
tca {
|
||||||
|
allowedTables = tt_content, fe_user
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
plugin {
|
plugin {
|
||||||
tx_searchcore {
|
tx_searchcore {
|
||||||
settings {
|
settings {
|
||||||
index {
|
indexer {
|
||||||
rootLineBlacklist = 3
|
tca {
|
||||||
|
rootLineBlacklist = 3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
plugin {
|
plugin {
|
||||||
tx_searchcore {
|
tx_searchcore {
|
||||||
settings {
|
settings {
|
||||||
index {
|
indexer {
|
||||||
tt_content {
|
tca {
|
||||||
additionalWhereClause = tt_content.CType NOT IN ('div')
|
tt_content {
|
||||||
|
additionalWhereClause = tt_content.CType NOT IN ('div')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue