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?
Views
Replies
Total Likes
Hi,
You can check below link for creating custom index in aem
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!
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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"
}
}
}
}
}
Views
Replies
Total Likes
Change reindex property to true
"reindex": true,
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Like
Replies
Views
Likes
Replies