Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Lucene index to search the keyword from a custom container

Avatar

Level 2

In our project we need to do a search feature, to check the keyword present inside jcr:content , of all the pages, need to check it is available or not in complete depth, we don't have any fixed paths or fixed container depth it can be as deep as possible , for example a component can be placed inside a accordion container , which is present inside a tabs container below is our indexing we are using to search

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:oak="http://jackrabbit.apache.org/oak/ns/1.0" xmlns:rep="internal" xmlns:cq="http://www.day.com/jcr/cq/1.0"
jcr:mixinTypes="[rep:AccessControllable]"
jcr:primaryType="nt:unstructured">
<search-custom-1
jcr:primaryType="oak:QueryIndexDefinition"
async="[async,nrt]"
compatVersion="{Long}2"
includedPaths="[/content/myproject]"
queryPaths="[/content/myproject]"
reindex="{Boolean}true"
evaluatePathRestrictions="{Boolean}true"
type="lucene">
<aggregates jcr:primaryType="nt:unstructured">
<cq:Page jcr:primaryType="nt:unstructured">
<include0
jcr:primaryType="nt:unstructured"
path="jcr:content"
relativeNode="{Boolean}true"/>
</cq:Page>
<nt:file jcr:primaryType="nt:unstructured">
<include0
jcr:primaryType="nt:unstructured"
path="jcr:content"/>
</nt:file>
<cq:PageContent jcr:primaryType="nt:unstructured">
<include0
jcr:primaryType="nt:unstructured"
path="*"/>
<include1
jcr:primaryType="nt:unstructured"
path="*/*"/>
<include2
jcr:primaryType="nt:unstructured"
path="*/*/*"/>
<include3
jcr:primaryType="nt:unstructured"
path="*/*/*/*"/>
</cq:PageContent>
</aggregates>
<indexRules jcr:primaryType="nt:unstructured">
<cq:Page
jcr:primaryType="nt:unstructured"
includePropertyTypes="[String,Binary]">
<properties jcr:primaryType="nt:unstructured">
<text
jcr:primaryType="nt:unstructured"
name="text"
propertyIndex="{Boolean}true"/>
<hoverCardtext
jcr:primaryType="nt:unstructured"
name="hoverCardtext"
propertyIndex="{Boolean}true"/>
<hideFromSearch
jcr:primaryType="nt:unstructured"
name="jcr:content/hideFromSearch"
propertyIndex="{Boolean}true"
nullCheckEnabled="{Boolean}true"/>
<columnOneHeader
jcr:primaryType="nt:unstructured"
name="columnOneHeader"
propertyIndex="{Boolean}true"/>
<columnTwoHeader
jcr:primaryType="nt:unstructured"
name="columnTwoHeader"
propertyIndex="{Boolean}true"/>
<columnThreeHeader
jcr:primaryType="nt:unstructured"
name="columnThreeHeader"
propertyIndex="{Boolean}true"/>
<columnFourHeader
jcr:primaryType="nt:unstructured"
name="columnFourHeader"
propertyIndex="{Boolean}true"/>
<linkLable
jcr:primaryType="nt:unstructured"
name="linkLable"
propertyIndex="{Boolean}true"/>
<cardTitle
jcr:primaryType="nt:unstructured"
name="cardTitle"
propertyIndex="{Boolean}true"/>
<subTitle
jcr:primaryType="nt:unstructured"
name="subTitle"
propertyIndex="{Boolean}true"/>
<imageCaption
jcr:primaryType="nt:unstructured"
name="imageCaption"
propertyIndex="{Boolean}true"/>
<cqPanelTitle
jcr:primaryType="nt:unstructured"
name="cq:panelTitle"
propertyIndex="{Boolean}true"/>
</properties>
</cq:Page>
<nt:base
jcr:primaryType="nt:unstructured"
includePropertyTypes="[String,Binary]">
<properties jcr:primaryType="nt:unstructured">
<cqTemplate
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="cq:template"/>
<globalcss
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="globalcss"/>
<jumpPageTarget
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="jumpPageTarget"/>
<loaderTheme
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="loaderTheme"/>
<slingResourceType
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="sling:resourceType"/>
<hideFromSearch
jcr:primaryType="nt:unstructured"
index="{Boolean}true"
name="hideFromSearch"/>
<desktopImgAlignment
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="desktopImgAlignment"/>
<mobileImgAlignment
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="mobileImgAlignment"/>
<tabImgAlignment
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="tabImgAlignment"/>
<backgroundVideoPosition
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="backgroundVideoPosition"/>
<bgImgAlignment
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="bgImgAlignment"/>
<alignment
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="alignment"/>
<alt
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="alt"/>
<id
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="id"/>
<fragmentPath
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="fragmentPath"/>
<fileReference
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="fileReference"/>
<titleAlignment
jcr:primaryType="nt:unstructured"
index="{Boolean}false"
name="titleAlignment"/>
</properties>
</nt:base>
</indexRules>
</search-custom-1>
</jcr:root>
 
Please provide any solution in the oak:index if we really can do that in depth level of searching for a keyword.
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Som_ChaithanyaGo 

This might be a starting point.

You can leverage the cq:PageContent aggregate in your Oak index definition.
The cq:PageContent aggregate allows you to index the content of components and their descendants recursively.

In your provided index definition, you have already included the cq:PageContent aggregate.
This configuration will index the content of the jcr:content node and its descendants up to four levels deep. However, if you need to search at any depth level, you can modify the include rules to include more levels or use a wildcard (*/*/*/*/*) to include all levels recursively.

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

@Som_ChaithanyaGo 

This might be a starting point.

You can leverage the cq:PageContent aggregate in your Oak index definition.
The cq:PageContent aggregate allows you to index the content of components and their descendants recursively.

In your provided index definition, you have already included the cq:PageContent aggregate.
This configuration will index the content of the jcr:content node and its descendants up to four levels deep. However, if you need to search at any depth level, you can modify the include rules to include more levels or use a wildcard (*/*/*/*/*) to include all levels recursively.

Avatar

Level 2

It worked we removed nt:base from the aggregator and gave nt:unstructred with same wildcard.Thanks @gkalyan 

Avatar

Administrator

@Som_ChaithanyaGo I hope you found the AEM community helpful. We look forward to seeing you return as either a learner or a mentor. The community flourishes with SMEs like you. Happy AEM learning!



Kautuk Sahni