Skip to content

Commit 0cc91db

Browse files
committed
Merge pull request #52 from Flowpack/cleanup
[TASK] Clean up code
2 parents 1276399 + 9a7f6c2 commit 0cc91db

4 files changed

Lines changed: 19 additions & 15 deletions

File tree

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Command/NodeIndexCommandController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function showMappingCommand() {
132132
* This command (re-)indexes all nodes contained in the content repository and sets the schema beforehand.
133133
*
134134
* @param integer $limit Amount of nodes to index at maximum
135-
* @param bool $update if TRUE, do not throw away the index at the start. Should *only be used for development*.
135+
* @param boolean $update if TRUE, do not throw away the index at the start. Should *only be used for development*.
136136
* @param string $workspace name of the workspace which should be indexed
137137
* @return void
138138
*/
@@ -223,7 +223,7 @@ protected function indexWorkspace($workspaceName) {
223223
* @param array $dimensions
224224
* @return void
225225
*/
226-
protected function indexWorkspaceWithDimensions($workspaceName, $dimensions = array()) {
226+
protected function indexWorkspaceWithDimensions($workspaceName, array $dimensions = array()) {
227227
$context = $this->contextFactory->create(array('workspaceName' => $workspaceName, 'dimensions' => $dimensions));
228228
$rootNode = $context->getRootNode();
229229

@@ -241,6 +241,7 @@ protected function indexWorkspaceWithDimensions($workspaceName, $dimensions = ar
241241

242242
/**
243243
* @param \TYPO3\TYPO3CR\Domain\Model\Node $currentNode
244+
* @return void
244245
*/
245246
protected function traverseNodes(\TYPO3\TYPO3CR\Domain\Model\Node $currentNode) {
246247

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Indexer/NodeIndexer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function getIndex() {
135135
* @param Node $node
136136
* @param string $targetWorkspaceName In case this is triggered during publishing, a workspace name will be passed in
137137
* @return void
138-
* @throws \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception\IndexingException
138+
* @throws \TYPO3\TYPO3CR\Search\Exception\IndexingException
139139
*/
140140
public function indexNode(Node $node, $targetWorkspaceName = NULL) {
141141
$contextPath = $node->getContextPath();
@@ -383,25 +383,25 @@ public function flush() {
383383
* Update the index alias
384384
*
385385
* @return void
386-
* @throws \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception
386+
* @throws Exception
387387
* @throws \Flowpack\ElasticSearch\Transfer\Exception\ApiException
388388
* @throws \Exception
389389
*/
390390
public function updateIndexAlias() {
391391
$aliasName = $this->searchClient->getIndexName(); // The alias name is the unprefixed index name
392392
if ($this->getIndexName() === $aliasName) {
393-
throw new \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception('UpdateIndexAlias is only allowed to be called when $this->setIndexNamePostfix has been created.', 1383649061);
393+
throw new Exception('UpdateIndexAlias is only allowed to be called when $this->setIndexNamePostfix has been created.', 1383649061);
394394
}
395395

396396
if (!$this->getIndex()->exists()) {
397-
throw new \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception('The target index for updateIndexAlias does not exist. This shall never happen.', 1383649125);
397+
throw new Exception('The target index for updateIndexAlias does not exist. This shall never happen.', 1383649125);
398398
}
399399

400400
$aliasActions = array();
401401
try {
402402
$response = $this->searchClient->request('GET', '/*/_alias/' . $aliasName);
403403
if ($response->getStatusCode() !== 200) {
404-
throw new \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception('The alias "' . $aliasName . '" was not found with some unexpected error... (return code: ' . $response->getStatusCode() . ')', 1383650137);
404+
throw new Exception('The alias "' . $aliasName . '" was not found with some unexpected error... (return code: ' . $response->getStatusCode() . ')', 1383650137);
405405
}
406406

407407
$indexNames = array_keys($response->getTreatedContent());
@@ -412,7 +412,7 @@ public function updateIndexAlias() {
412412
if ($response->getStatusCode() === 200) {
413413
$response = $this->searchClient->request('DELETE', '/' . $aliasName);
414414
if ($response->getStatusCode() !== 200) {
415-
throw new \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception('The index "' . $aliasName . '" could not be removed to be replaced by an alias. (return code: ' . $response->getStatusCode() . ')', 1395419177);
415+
throw new Exception('The index "' . $aliasName . '" could not be removed to be replaced by an alias. (return code: ' . $response->getStatusCode() . ')', 1395419177);
416416
}
417417
}
418418
} else {

Documentation/Index.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ TYPO3 Flow Package for indexing Nodes from TYPO3 Neos to ElasticSearch.
99
Setup
1010
-----
1111

12-
To be able indexing nodes into ElasticSearch there must be an index at all. This has to be 'neos'.
12+
To be able indexing nodes into ElasticSearch there must be an index at all.
1313
This can be created on console like this when the ElasticSearch Server is running::
1414

15-
curl -XPUT 'http://localhost:9200/neos/'
15+
curl -XPUT 'http://localhost:9200/typo3cr/'
1616

1717
Other wise you get an error message like this::
1818

1919
{
20-
"error" : "IndexMissingException[[neos] missing]",
20+
"error" : "IndexMissingException[[typo3cr] missing]",
2121
"status" : 404
2222
}
2323

24-
To be sure that the 'neos' index was created use the following url in your browser::
24+
To be sure that the 'typo3cr' index was created use the following url in your browser::
2525

26-
http://localhost:9200/neos/_search?pretty
26+
http://localhost:9200/typo3cr/_search?pretty
2727

2828
The output should be like this::
2929

@@ -41,3 +41,7 @@ The output should be like this::
4141
"hits" : [ ]
4242
}
4343
}
44+
45+
It is recommended to use an index name that corresponds to the project you are indexing to avoid
46+
clashes by using the same index in different projects. The index name can be changed in the
47+
settings.

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"name": "flowpack/elasticsearch-contentrepositoryadaptor",
33
"type": "typo3-flow-package",
4-
"description": "This package provides functionality for the interaction of elasticsearch engine and TYPO3CR.",
4+
"description": "This package provides functionality for using Elasticsearch on top of TYPO3CR.Search",
55
"homepage": "http://flowpack.org/",
66
"license": ["LGPL-3.0+"],
77
"require": {
88
"flowpack/elasticsearch": "*",
99
"typo3/eel": "*",
10-
"typo3/typo3cr": "*",
1110
"typo3/typo3cr-search": "*"
1211
},
1312
"autoload": {

0 commit comments

Comments
 (0)