I have a SQL2 query that needs indexing: SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/homepage/jcr:content])
But I got this error:
no proper index was found for filter Filter(query=explain SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/homepage/jcr:content]) , path=/content/homepage/jcr:content//*) Traversal query (query without index): explain SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/homepage/jcr:content]) ; consider creating an index
I was wondering which field I could create index for here? Because I don't see any fields being used that I can index...
Thanks~!
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Based on your query, which is selecting all nodes within a certain sub-tree in the repository, you will want to create an index that optimizes for path queries. Since your query does not filter based on properties but rather on the node’s position in the repository hierarchy, a path index is the most suitable. Here is a breakdown of the recommended steps to create a path index based on the AEM documentation:
Here’s an example of what the node structure for your index definition might look like in CRX DE:
<homepageDescendants jcr:primaryType="oak:QueryIndexDefinition" type="path" reindex="true"> <indexRules jcr:primaryType="nt:unstructured"> <nt:base jcr:primaryType="nt:unstructured"> <properties jcr:primaryType="nt:unstructured"> <path jcr:primaryType="nt:unstructured" name="jcr:path" unique="false"/> </properties> </nt:base> </indexRules> <includedPaths jcr:primaryType="nt:unstructured"> <content jcr:primaryType="nt:unstructured" name="/content/homepage/jcr:content"/> </includedPaths> </homepageDescendants>
This structure tells AEM to index the paths under `/content/homepage/jcr:content`, which should optimize your query. For further reading and more detailed instructions on how to create and manage custom indexes, you can refer to the following documentation:
GO to this url https://oakutils.appspot.com/generate/index
paste query and generate index definition, copy xml format and add to oak:index/.content.xml and update filter.xml to deploy
Based on your query, which is selecting all nodes within a certain sub-tree in the repository, you will want to create an index that optimizes for path queries. Since your query does not filter based on properties but rather on the node’s position in the repository hierarchy, a path index is the most suitable. Here is a breakdown of the recommended steps to create a path index based on the AEM documentation:
Here’s an example of what the node structure for your index definition might look like in CRX DE:
<homepageDescendants jcr:primaryType="oak:QueryIndexDefinition" type="path" reindex="true"> <indexRules jcr:primaryType="nt:unstructured"> <nt:base jcr:primaryType="nt:unstructured"> <properties jcr:primaryType="nt:unstructured"> <path jcr:primaryType="nt:unstructured" name="jcr:path" unique="false"/> </properties> </nt:base> </indexRules> <includedPaths jcr:primaryType="nt:unstructured"> <content jcr:primaryType="nt:unstructured" name="/content/homepage/jcr:content"/> </includedPaths> </homepageDescendants>
This structure tells AEM to index the paths under `/content/homepage/jcr:content`, which should optimize your query. For further reading and more detailed instructions on how to create and manage custom indexes, you can refer to the following documentation:
Thanks for your reply! This is super thorough. I was wondering if I have thousands of pages, do I need to add these paths one by one like below?
<includedPaths jcr:primaryType="nt:unstructured"> <content jcr:primaryType="nt:unstructured" name="/content/homepage0/jcr:content"/>
<content jcr:primaryType="nt:unstructured" name="/content/homepage1/jcr:content"/>
<content jcr:primaryType="nt:unstructured" name="/content/homepage2/jcr:content"/> </includedPaths>
I was wondering if there's any better way to do this?