Skip to content

Commit a93b9cb

Browse files
committed
Merge pull request #76 from ttreeagency/Bugfix/ChangeNodeType
[BUGFIX] After changing NodeType indexes contains two documents
2 parents 469fb34 + 0b0137c commit a93b9cb

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Indexer

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,24 @@ public function indexNode(NodeInterface $node, $targetWorkspaceName = NULL) {
129129

130130
$mappingType = $this->getIndex()->findType(NodeTypeMappingBuilder::convertNodeTypeNameToMappingName($nodeType));
131131

132+
// Remove document with the same contextPathHash but different NodeType, required after NodeType change
133+
$this->getIndex()->request('DELETE', '/_query', array(), json_encode([
134+
'query' => [
135+
'bool' => [
136+
'must' => [
137+
'ids' => [
138+
'values' => [ $contextPathHash ]
139+
]
140+
],
141+
'must_not' => [
142+
'term' => [
143+
'_type' => str_replace('.', '/', $node->getNodeType()->getName())
144+
]
145+
],
146+
]
147+
]
148+
]));
149+
132150
if ($node->isRemoved()) {
133151
// TODO: handle deletion from the fulltext index as well
134152
$mappingType->deleteDocumentById($contextPathHash);

0 commit comments

Comments
 (0)