Skip to content

Commit

Permalink
NGSTACK-836 add parent child indexing compiler pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Katarina Miočić committed Mar 25, 2024
1 parent ad0b014 commit 0aaa15b
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private function processExtensionConfiguration(array $configs, ContainerBuilder
$this->processIndexableFieldTypeConfiguration($configuration, $container);
$this->processSearchResultExtractorConfiguration($configuration, $container);
$this->processAsynchronousIndexingConfiguration($configuration, $container);
$this->processParentChildIndexingConfiguration($configuration, $container);
}

private function processSearchResultExtractorConfiguration(array $configuration, ContainerBuilder $container): void
Expand Down Expand Up @@ -117,4 +118,12 @@ private function processAsynchronousIndexingConfiguration(array $configuration,
$configuration['use_asynchronous_indexing'],
);
}

private function processParentChildIndexingConfiguration(array $configuration, ContainerBuilder $container): void
{
$container->setParameter(
'netgen_ibexa_search_extra.use_parent_child_indexing',
$configuration['use_parent_child_indexing'],
);
}
}
2 changes: 2 additions & 0 deletions bundle/NetgenIbexaSearchExtraBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Netgen\Bundle\IbexaSearchExtraBundle;

use Netgen\IbexaSearchExtra\Container\Compiler;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

Expand All @@ -21,6 +22,7 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new Compiler\AggregateFacetBuilderVisitorPass());
$container->addCompilerPass(new Compiler\AggregateSubdocumentQueryCriterionVisitorPass());
$container->addCompilerPass(new Compiler\AsynchronousIndexingPass());
$container->addCompilerPass(new Compiler\ParentChildIndexingPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 100);
$container->addCompilerPass(new Compiler\FieldType\RichTextIndexablePass());
$container->addCompilerPass(new Compiler\SearchResultExtractorPass());
$container->addCompilerPass(new Compiler\RawFacetBuilderDomainVisitorPass());
Expand Down
31 changes: 31 additions & 0 deletions lib/Container/Compiler/ParentChildIndexingPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Netgen\IbexaSearchExtra\Container\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class ParentChildIndexingPass implements CompilerPassInterface
{
private const ParentChildIndexerTag = 'netgen.parent_child_indexer.message_handler';
private const MessageHandlerTag = 'messenger.message_handler';

public function process(ContainerBuilder $container) :void
{
$useParentChildIndexing = $container->getParameter(
'netgen_ibexa_search_extra.use_parent_child_indexing',
);

if ($useParentChildIndexing !== true) {
return;
}

$serviceIds =$container->findTaggedServiceIds(self::ParentChildIndexerTag);

foreach ($serviceIds as $serviceId => $tag) {
$definition = $container->getDefinition($serviceId);
$definition->addTag(self::MessageHandlerTag);
}

}
}
12 changes: 1 addition & 11 deletions lib/Resources/config/search/common/parent_child_indexing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,4 @@ imports:
- { resource: parent_child_indexing/trash.yaml }

parameters:
netgen.ibexa_search_extra.parent_child_indexer:
parent_content:
children:
child_content:
indexed: true
children:
child_content:
indexed: true
children:
child_content:
indexed: true
netgen.ibexa_search_extra.parent_child_indexer: []
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ services:
- '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Content\DeleteContentHandler:
arguments:
- '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Content\DeleteTranslationHandler:
Expand All @@ -22,29 +22,29 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Content\HideContentHandler:
arguments:
- '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Content\PublishVersionHandler:
arguments:
- '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Content\RevealContentHandler:
arguments:
- '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Content\UpdateContentMetadataHandler:
arguments:
Expand All @@ -53,5 +53,5 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Location\CopySubtreeHandler:
Expand All @@ -14,7 +14,7 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Location\CreateLocationHandler:
Expand All @@ -23,7 +23,7 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Location\DeleteLocationHandler:
Expand All @@ -32,7 +32,7 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Location\HideLocationHandler:
Expand All @@ -41,7 +41,7 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Location\MoveSubtreeHandler:
Expand All @@ -50,7 +50,7 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Location\SwapLocationHandler:
Expand All @@ -59,7 +59,7 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Location\UnhideLocationHandler:
Expand All @@ -68,7 +68,7 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Location\UpdateLocationHandler:
Expand All @@ -77,5 +77,5 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ services:
- '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ services:
- '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\Trash\TrashHandler:
Expand All @@ -14,5 +14,5 @@ services:
- '@Netgen\IbexaSearchExtra\Core\Search\Common\Messenger\MessageHandler\Search\ParentChildIndexing\AncestorIndexer'
- '@?logger'
tags:
- { name: messenger.message_handler }
- { name: netgen.parent_child_indexer.message_handler }
- { name: monolog.logger, channel: ngsearchextra }

0 comments on commit 0aaa15b

Please sign in to comment.