AEM doesn't use OOTB Lucene Index with query
Greetings,
I am executing the following query (xpath):
/jcr:root/content/tnc/nature/us/en-us/test-pages/general-content-test/jcr:content//*[(jcr:like(@sling:resourceType, 'tnc/components/%') and @10922553:resourceType != 'tnc/components/content/anchor-links' and @10922553:resourceType != 'tnc/components/content/tab-container' and @10922553:resourceType != 'tnc/components/element/tab-element')]
The query works fine and returns the expected results. However, I expect it to use the OOTB lucene index: '/oak:index/ntBaseLucene', but it only does so on my local environment. On our DEV/QA/STAGE and PROD environments, the index is not used and the query executes via traversal.
Here is the response from the 'Explain Query' tool on QA:
Parsing JCR-SQL2 statement: explain select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] like 'tnc/components/%' and [sling:resourceType] <> 'tnc/components/content/anchor-links' and [sling:resourceType] <> 'tnc/components/content/tab-container' and [sling:resourceType] <> 'tnc/components/element/tab-element' and isdescendantnode(a, '/content/tnc/nature/us/en-us/test-pages/general-content-test/jcr:content')
cost using filter Filter(query=explain select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] like 'tnc/components/%' and [sling:resourceType] <> 'tnc/components/content/anchor-links' and [sling:resourceType] <> 'tnc/components/content/tab-container' and [sling:resourceType] <> 'tnc/components/element/tab-element' and isdescendantnode(a, '/content/tnc/nature/us/en-us/test-pages/general-content-test/jcr:content'), path=/content/tnc/nature/us/en-us/test-pages/general-content-test/jcr:content//*, property=[sling:resourceType=[(tnc/components/%.., is not null]])
cost for reference is Infinity
cost for property is Infinity
cost for nodeType is Infinity
Refreshed reader for index [Fulltext Index : /oak:index/fragments] [took 1ms]
Refreshed reader for index [Fulltext Index : /oak:index/damAssetLucene] [took 1ms]
cost for lucene-property is Infinity
cost for aggregate lucene is Infinity
looking for plans for paths : []
cost for aggregate solr is Infinity
cost for traverse is 2000.0
no proper index was found for filter Filter(query=explain select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] like 'tnc/components/%' and [sling:resourceType] <> 'tnc/components/content/anchor-links' and [sling:resourceType] <> 'tnc/components/content/tab-container' and [sling:resourceType] <> 'tnc/components/element/tab-element' and isdescendantnode(a, '/content/tnc/nature/us/en-us/test-pages/general-content-test/jcr:content'), path=/content/tnc/nature/us/en-us/test-pages/general-content-test/jcr:content//*, property=[sling:resourceType=[(tnc/components/%.., is not null]])
Traversal query (query without index): explain select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] like 'tnc/components/%' and [sling:resourceType] <> 'tnc/components/content/anchor-links' and [sling:resourceType] <> 'tnc/components/content/tab-container' and [sling:resourceType] <> 'tnc/components/element/tab-element' and isdescendantnode(a, '/content/tnc/nature/us/en-us/test-pages/general-content-test/jcr:content'); consider creating an index
Here is the ntBaseLucene index node from QA that I expect to be used with this query.
{
"jcr:primaryType":"oak:QueryIndexDefinition",
"compatVersion":2,
"supersedes":[
"/oak:index/cqDefaultFormFor",
"/oak:index/fpContentType",
"/oak:index/cqOwnerCanvasPage",
"/oak:index/cqVariantFamily",
"/oak:index/damStatus",
"/oak:index/campaignpath",
"/oak:index/slingVanityPath",
"/oak:index/type",
"/oak:index/contentPath",
"/oak:index/cq:masterBuildingBlockPath",
"/oak:index/containeeInstanceId",
"/oak:index/cqCloudServiceConfigs",
"/oak:index/slingAlias",
"/oak:index/cqCugEnabled",
"/oak:index/active",
"/oak:index/cq:masterBuildingBlock",
"/oak:index/cqAcUUID",
"/oak:index/cqKeywords",
"/oak:index/cqCloudServiceConfig",
"/oak:index/cqConf",
"/oak:index/cq:targetOfferId",
"/oak:index/postId",
"/oak:index/verb",
"/oak:index/extensionType",
"/oak:index/fpNodeType",
"/oak:index/guideComponentType",
"/oak:index/cqMaster",
"/oak:index/cqIsCommunitySite",
"/oak:index/deviceIdentificationMode",
"/oak:index/lockCreated",
"/oak:index/processingProfile",
"/oak:index/ec-uuid",
"/oak:index/slingResources",
"/oak:index/slingResourceType",
"/oak:index/subType",
"/oak:index/slingResourceSuperType",
"/oak:index/damS7watch",
"/oak:index/jcrLockOwner",
"/oak:index/cqTemplate",
"/oak:index/fragmentPath"
],
"seed":-8469734158828420701,
"type":"lucene",
"async":[
"async",
"nrt"
],
"evaluatePathRestrictions":true,
"reindex":false,
"reindexCount":1,
"indexRules":{
"jcr:primaryType":"nt:unstructured",
"nt:base":{
"jcr:primaryType":"nt:unstructured",
"properties":{
"jcr:primaryType":"nt:unstructured",
"resourceType":{
"jcr:primaryType":"nt:unstructured",
"valueExcludedPrefixes":["slingevent:Job","sling:Folder"],
"name":"sling:resourceType",
"sync":true
}
}
}
}
}
Here is an example of a node that would be returned by the query. It is located at: /content/tnc/nature/us/en-us/test-pages/general-content-test/jcr:content/body/image
{
"jcr:primaryType":"nt:unstructured",
"jcr:createdBy":"",
"jcr:lastModifiedBy":"",
"cvariationVideo":"medium",
"desktopImageCrop":"left-top",
"jcr:created":"Tue Mar 25 2025 20:03:03 GMT+0000",
"verticalHorizontalSelection":"no",
"mobileImageCrop":"center-middle",
"jcr:lastModified":"Tue Mar 25 2025 20:04:14 GMT+0000",
"sling:resourceType":"tnc/components/content/image",
"compVariation":"img-vari",
"backgroundImg1":"/content/dam/tnc/nature/en/",
"cvariation":"medium"
}
Any thoughts on why the index is being ignored or how I might further debug? Should I reindex? Thank you!