Search working only on Title and URL - Lucene index | Community
Skip to main content
ashishkhadpe
Level 3
February 4, 2021
Solved

Search working only on Title and URL - Lucene index

  • February 4, 2021
  • 1 reply
  • 881 views

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')
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lucian_nicolaescu

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.

1 reply

lucian_nicolaescuAccepted solution
Level 2
February 4, 2021

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.