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
BedrockMission!

Learn More

View all

Sign in to view all badges

How to Index a Node Name?

Avatar

Avatar
Validate 1
Level 3
DhirajAg
Level 3

Likes

12 likes

Total Posts

65 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile

Avatar
Validate 1
Level 3
DhirajAg
Level 3

Likes

12 likes

Total Posts

65 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile
DhirajAg
Level 3

19-04-2019

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?

Replies

Avatar

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

74 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

74 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile
Ravi_Pampana
MVP

20-04-2019

Hi,

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!

Avatar

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile
Gaurav-Behl
MVP

20-04-2019

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

Avatar

Avatar
Validate 1
Level 3
DhirajAg
Level 3

Likes

12 likes

Total Posts

65 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile

Avatar
Validate 1
Level 3
DhirajAg
Level 3

Likes

12 likes

Total Posts

65 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile
DhirajAg
Level 3

20-04-2019

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"

                    }

               }

          }

     }

}

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

20-04-2019

Change reindex property to true

"reindex": true,

Avatar

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile
Gaurav-Behl
MVP

20-04-2019

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