Expand my Community achievements bar.

SOLVED

Search working only on Title and URL - Lucene index

Avatar

Level 4

Hi Everyone,

 

We have just upgraded to AEM 6.5. Previously on AEM 6.2 version, our search functionality was not using any index but by traversing the node was giving the results. With AEM 6.5, we have fixed our lucene index and our search is using the index now to search.

Issue we are facing now is that when we search for any term, it only uses the URI and title of the page to search. Is there any configuration using which I can force my lucene index to search within body of my page as well?

 

My query looks like below :

select [jcr:path], [jcr:score], [rep:excerpt] from [nt:hierarchyNode] as a where isdescendantnode(a, '/content/mysite') and [jcr:content/hideFromSearch] is null and contains([jcr:content/*], 'Media')
1 Accepted Solution

Avatar

Correct answer by
Level 2

You can and should add an index like:

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:oak="http://jackrabbit.apache.org/oak/ns/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
    xmlns:dam="http://www.day.com/dam/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="oak:Unstructured"
    async="async"
    compatVersion="{Long}2"
    evaluatePathRestrictions="{Boolean}true"
    functionName="my-custom-search-index"
    includedPaths="/content"
    reindex="{Boolean}true"
    reindexCount="{Long}0"
    type="lucene">
    <aggregates jcr:primaryType="nt:unstructured">
        <cq:Page jcr:primaryType="nt:unstructured">
            <include0
                jcr:primaryType="nt:unstructured"
                path="jcr:content/*"
                relativeNode="{Boolean}true"/>
            <include1
                jcr:primaryType="nt:unstructured"
                path="jcr:content/*/*"
                relativeNode="{Boolean}true"/>
            <!-- how deep you want to go or something like (/.+)* -->
        </cq:Page>
    </aggregates>
    <indexRules jcr:primaryType="nt:unstructured">
        <cq:Page
            jcr:primaryType="nt:unstructured"
            includePropertyTypes="all">
            <properties jcr:primaryType="nt:unstructured">
                <cqTags
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/cq:tags"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <jcrTitle
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/jcr:title"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <text
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content(/.+)*/text"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <!-- Other "properties" that you want to index, because you don't want to index dates or I don't know -->
            </properties>
        </cq:Page>
        <dam:Asset
            jcr:primaryType="nt:unstructured"
            includePropertyTypes="all">
            <properties jcr:primaryType="nt:unstructured">
                <jcrTitle
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/metadata/jcr:title"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <cqName
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/cq:name"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <dcTitle
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/metadata/dc:title"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <dcDescription
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/metadata/dc:description"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <cqAssetTags
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/metadata/cq:tags"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
            </properties>
        </dam:Asset>
    </indexRules>
</jcr:root>

 

 

More details about indexes here: https://jackrabbit.apache.org/oak/docs/query/lucene.html 

You can also check your indexes here: http://localhost:4502/libs/granite/operations/content/diagnosistools/indexManager.html 

PS: make sure your index is deployed... and reindex triggered when you make changes to the index definition.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

You can and should add an index like:

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:oak="http://jackrabbit.apache.org/oak/ns/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
    xmlns:dam="http://www.day.com/dam/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="oak:Unstructured"
    async="async"
    compatVersion="{Long}2"
    evaluatePathRestrictions="{Boolean}true"
    functionName="my-custom-search-index"
    includedPaths="/content"
    reindex="{Boolean}true"
    reindexCount="{Long}0"
    type="lucene">
    <aggregates jcr:primaryType="nt:unstructured">
        <cq:Page jcr:primaryType="nt:unstructured">
            <include0
                jcr:primaryType="nt:unstructured"
                path="jcr:content/*"
                relativeNode="{Boolean}true"/>
            <include1
                jcr:primaryType="nt:unstructured"
                path="jcr:content/*/*"
                relativeNode="{Boolean}true"/>
            <!-- how deep you want to go or something like (/.+)* -->
        </cq:Page>
    </aggregates>
    <indexRules jcr:primaryType="nt:unstructured">
        <cq:Page
            jcr:primaryType="nt:unstructured"
            includePropertyTypes="all">
            <properties jcr:primaryType="nt:unstructured">
                <cqTags
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/cq:tags"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <jcrTitle
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/jcr:title"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <text
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content(/.+)*/text"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <!-- Other "properties" that you want to index, because you don't want to index dates or I don't know -->
            </properties>
        </cq:Page>
        <dam:Asset
            jcr:primaryType="nt:unstructured"
            includePropertyTypes="all">
            <properties jcr:primaryType="nt:unstructured">
                <jcrTitle
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/metadata/jcr:title"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <cqName
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/cq:name"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <dcTitle
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/metadata/dc:title"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <dcDescription
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/metadata/dc:description"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
                <cqAssetTags
                    jcr:primaryType="nt:unstructured"
                    analyzed="{Boolean}true"
                    isRegexp="{Boolean}false"
                    name="jcr:content/metadata/cq:tags"
                    nodeScopeIndex="{Boolean}true"
                    propertyIndex="{Boolean}false"
                    type="String"/>
            </properties>
        </dam:Asset>
    </indexRules>
</jcr:root>

 

 

More details about indexes here: https://jackrabbit.apache.org/oak/docs/query/lucene.html 

You can also check your indexes here: http://localhost:4502/libs/granite/operations/content/diagnosistools/indexManager.html 

PS: make sure your index is deployed... and reindex triggered when you make changes to the index definition.