Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How to Index a Node Name?


Level 4

I have a query where I am trying to find a node through its name. My sample query is below

SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/abc]) and NAME(s) = 'testNode'

I am trying to find nodes under /content/abc with the name as 'testNode' and I get in the log that i should try to index it. How can i achieve this? Can you share a sample index definition for indexing a node name?

0 Replies


Community Advisor


You can check below link for creating custom index in aem

Oak Queries and Indexing

Instead of finding the node try to query using resourceType if available, as node name might have random number when same component is used more than once under a node, also using resourceType will have oak:index already available and no custom index need to be added.

Using type = cq:pagecontent (primary type of jcr:content) property in query builder will improve load time and also add p.guesstotal= true as a best practice.

Hope this helps!


Community Advisor

Create a lucene index as mentioned in the link shared by Ravi, set 'indexNodeName' and  evaluatePathRestrictions to true

- compatVersion = 2

  - async = "async"

  - jcr:primaryType = oak:QueryIndexDefinition

  - evaluatePathRestrictions = true    // to index node names under a specific path like /content/abc

  - type = "lucene"   

  + indexRules

   + nt:base        //   this is your node name that you want to index/run query against

   - indexNodeName = true   // to index node names

    + properties                      

Jackrabbit Oak – Lucene Index

Oak Utilities : Index Definition Generator


Level 4

Hi Gaurav,

I have tried the same and it is not working for me. I stil get the error to consider creating an index.

Here is my query

select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'audience' and isdescendantnode(a, '/apps/weretail/components/templates/testpage')

and my index definition below


     "jcr:primaryType": "oak:QueryIndexDefinition",

     "compatVersion": 2,

     "type": "lucene",

     "async": "async",

     "evaluatePathRestrictions": true,

     "reindex": false,

     "reindexCount": 14,

     "indexRules": {

          "jcr:primaryType": "nt:unstructured",

          "audience": {

               "jcr:primaryType": "nt:unstructured",

               "indexNodeName": true,

               "properties": {

                    "jcr:primaryType": "nt:unstructured",

                    "path": {

                         jcr:primaryType": "nt:unstructured",

                         "ordered": true,

                         "propertyIndex": true,

                         "name": "path"







Community Advisor

Change reindex property to true

"reindex": true,


Community Advisor

I'm not able to understand the purpose of indexing component node  ---- isdescendantnode(a, '/apps/weretail/components/templates/testpage')

Compare your index-definition against OOB sample ---  /oak:index/socialLucene/indexRules/social:asiResource

Debug using index manager/jmx. Check if the index is configured correctly?

Check the error.log when you set reindex to true for clues

you may include excludedPaths and queryPaths for this index