Skip to content

Commit 136b7b1

Browse files
committed
TASK: Remove unneeded deleteDuplicateDocumentNotMatchingType
As we don not have real types in ES 6 / ES 7, it is not possible to have two documents with the same identifier and different types. Changing the nodeType will change the one document with the calculated identifier. Therefore the deleteDuplicateDocumentNotMatchingType is not needed anymore.
1 parent cc8251a commit 136b7b1

File tree

3 files changed

+0
-70
lines changed

3 files changed

+0
-70
lines changed

Classes/Driver/DocumentDriverInterface.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,4 @@ interface DocumentDriverInterface
3131
* @return array
3232
*/
3333
public function delete(NodeInterface $node, string $identifier): array;
34-
35-
/**
36-
* Delete documents by $documentIdentifier not having the given $nodeType
37-
*
38-
* @param Index $index
39-
* @param string $documentIdentifier
40-
* @param NodeType $nodeType
41-
* @return void
42-
*/
43-
public function deleteDuplicateDocumentNotMatchingType(Index $index, string $documentIdentifier, NodeType $nodeType): void;
4434
}

Classes/Driver/Version6/DocumentDriver.php

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -43,58 +43,4 @@ public function delete(NodeInterface $node, string $identifier): array
4343
]
4444
];
4545
}
46-
47-
/**
48-
* {@inheritdoc}
49-
* @throws \Flowpack\ElasticSearch\Exception
50-
* @throws \Neos\Flow\Http\Exception
51-
*/
52-
public function deleteDuplicateDocumentNotMatchingType(Index $index, string $documentIdentifier, NodeType $nodeType): void
53-
{
54-
$result = $index->request('GET', '/_search?scroll=1m', [], json_encode([
55-
'sort' => ['_doc'],
56-
'query' => [
57-
'bool' => [
58-
'must' => [
59-
'ids' => [
60-
'values' => [$documentIdentifier]
61-
]
62-
],
63-
'must_not' => [
64-
'term' => [
65-
Mapping::NEOS_TYPE_FIELD => $nodeType->getName()
66-
]
67-
]
68-
]
69-
]
70-
]));
71-
$treatedContent = $result->getTreatedContent();
72-
$scrollId = $treatedContent['_scroll_id'];
73-
$mapHitToDeleteRequest = static function ($hit) {
74-
return json_encode([
75-
'delete' => [
76-
'_id' => $hit['_id']
77-
]
78-
]);
79-
};
80-
$bulkRequest = [];
81-
while (isset($treatedContent['hits']['hits']) && $treatedContent['hits']['hits'] !== []) {
82-
$hits = $treatedContent['hits']['hits'];
83-
$bulkRequest = array_merge($bulkRequest, array_map($mapHitToDeleteRequest, $hits));
84-
$result = $index->request('POST', '/_search/scroll', [], json_encode([
85-
'scroll' => '1m',
86-
'scroll_id' => $scrollId,
87-
]), false);
88-
$treatedContent = $result->getTreatedContent();
89-
}
90-
$this->logger->debug(sprintf('NodeIndexer: Check duplicate nodes for %s (%s), found %d document(s)', $documentIdentifier, $nodeType->getName(), count($bulkRequest)), LogEnvironment::fromMethodName(__METHOD__));
91-
if ($bulkRequest !== []) {
92-
$index->request('POST', '/_bulk', [], implode("\n", $bulkRequest) . "\n");
93-
}
94-
$this->searchClient->request('DELETE', '/_search/scroll', [], json_encode([
95-
'scroll_id' => [
96-
$scrollId
97-
]
98-
]));
99-
}
10046
}

Classes/Indexer/NodeIndexer.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,6 @@ public function indexNode(NodeInterface $node, $targetWorkspaceName = null): voi
261261

262262
$mappingType = $this->getIndex()->findType($nodeType->getName());
263263

264-
if ($this->bulkProcessing === false) {
265-
// Remove document with the same contextPathHash but different NodeType, required after NodeType change
266-
$this->logger->debug(sprintf('Search and remove duplicate document for node %s (%s) if needed.', $contextPath, $node->getIdentifier()), LogEnvironment::fromMethodName(__METHOD__));
267-
$this->documentDriver->deleteDuplicateDocumentNotMatchingType($this->getIndex(), $documentIdentifier, $node->getNodeType());
268-
}
269-
270264
$fulltextIndexOfNode = [];
271265
$nodePropertiesToBeStoredInIndex = $this->extractPropertiesAndFulltext($node, $fulltextIndexOfNode, function ($propertyName) use ($documentIdentifier, $node) {
272266
$this->logger->debug(sprintf('Property "%s" not indexed because no configuration found, node type %s.', $propertyName, $node->getNodeType()->getName()), LogEnvironment::fromMethodName(__METHOD__));

0 commit comments

Comments
 (0)