Skip to content

nodeindex:build indexes into old index when ContentRepositoryQueueIndexer is installed #424

@paavo

Description

@paavo

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 WorkspaceIndexerNodeIndexingManagerflushQueues() 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions