Bug
nodeindex:build indexes all nodes into the current (old) index via the alias, then switches the alias to the new (empty) index. Expected behavior is to index into the new index first, then switch the alias.
Cause
NodeIndexCommandController injects the concrete NodeIndexer class:
/**
* @Flow\Inject
* @var NodeIndexer
*/
protected $nodeIndexer;
When Flowpack.ElasticSearch.ContentRepositoryQueueIndexer is installed, its Objects.yaml overrides NodeIndexerInterface to point to ContentRepositoryQueueIndexer\Indexer\NodeIndexer. This creates two separate singleton instances:
- Instance A (
ContentRepositoryAdaptor\Indexer\NodeIndexer) – used by NodeIndexCommandController
- Instance B (
ContentRepositoryQueueIndexer\Indexer\NodeIndexer) – used by NodeIndexingManager (injected via NodeIndexerInterface)
configureNodeIndexer() sets the postfix on Instance A, but WorkspaceIndexer → NodeIndexingManager → flushQueues() calls indexNode() on Instance B, which has no postfix. getIndexName() returns the alias name, so Elasticsearch routes documents to the old index.
Suggested fix
Inject NodeIndexerInterface instead of the concrete class in NodeIndexCommandController:
use Neos\ContentRepository\Search\Indexer\NodeIndexerInterface;
/**
* @Flow\Inject
* @var NodeIndexerInterface
*/
protected $nodeIndexer;
Related