Skip to content

Commit

Permalink
fragment config isn't indexed by pages #10047
Browse files Browse the repository at this point in the history
  • Loading branch information
vbradnitski committed Feb 24, 2023
1 parent d7a2239 commit 5b28cba
Show file tree
Hide file tree
Showing 2 changed files with 198 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public class PageRegionsConfigProcessor

static final String VALUE = "value";

static final IndexConfig TEXT_COMPONENT_INDEX_CONFIG = IndexConfig.create( IndexConfig.FULLTEXT ).
addIndexValueProcessor( IndexValueProcessors.HTML_STRIPPER ).
build();
static final IndexConfig TEXT_COMPONENT_INDEX_CONFIG =
IndexConfig.create( IndexConfig.FULLTEXT ).addIndexValueProcessor( IndexValueProcessors.HTML_STRIPPER ).build();

private final PartDescriptorService partDescriptorService;

Expand Down Expand Up @@ -71,6 +70,7 @@ public PatternIndexConfigDocument.Builder processDocument( final PatternIndexCon
builder.add( String.join( ELEMENT_DIVIDER, COMPONENTS, LayoutComponentType.INSTANCE.toString(), DESCRIPTOR ), IndexConfig.MINIMAL );

processPageRegions( page.getRegions(), builder );
processPageFragment( page.getFragment(), builder );

return builder;
}
Expand All @@ -85,18 +85,28 @@ private void processPageRegions( final PageRegions pageRegions, final PatternInd
pageRegions.forEach( pageRegion -> processComponents( pageRegion.getComponents(), builder ) );
}

private void processPageFragment( final Component fragment, final PatternIndexConfigDocument.Builder builder )
{
if ( fragment == null )
{
return;
}

processComponents( List.of( fragment ), builder );
}

private void processComponents( final List<Component> components, final PatternIndexConfigDocument.Builder builder )
{
if ( components == null )
{
return;
}

components.stream().
filter( component -> component instanceof DescriptorBasedComponent ).
map( component -> (DescriptorBasedComponent) component ).
filter( DescriptorBasedComponent::hasDescriptor ).
forEach( component -> processDescriptorBasedComponent( component, builder ) );
components.stream()
.filter( component -> component instanceof DescriptorBasedComponent )
.map( component -> (DescriptorBasedComponent) component )
.filter( DescriptorBasedComponent::hasDescriptor )
.forEach( component -> processDescriptorBasedComponent( component, builder ) );
}

private void processDescriptorBasedComponent( final DescriptorBasedComponent component,
Expand All @@ -108,6 +118,7 @@ private void processDescriptorBasedComponent( final DescriptorBasedComponent com
final IndexConfigVisitor indexConfigVisitor = new IndexConfigVisitor(
String.join( ELEMENT_DIVIDER, COMPONENTS, component.getType().toString(), CONFIG, appNameAsString, componentNameAsString ),
builder );

indexConfigVisitor.traverse( getComponentConfig( component ) );

builder.add(
Expand Down
Loading

0 comments on commit 5b28cba

Please sign in to comment.