Expand my Community achievements bar.

SOLVED

INvalid query exception

Avatar

Level 6

Hi,

I'm getting invalide query exception for this 

String queryString = "SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node," +path+")"+ "AND [sling:resourceType] LIKE 'apps/components/componentName";
 
I tried String queryString = "SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node," +path+")"+ "AND [sling:resourceType] = 'apps/components/componentName"; also
Any suggestions?
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Try this 

String queryString = "SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node,'"+path+"')"+"AND node.[sling:resourceType] = 'apps/components/componentName'";

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Try this 

String queryString = "SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node,'"+path+"')"+"AND node.[sling:resourceType] = 'apps/components/componentName'";

Avatar

Community Advisor

Hi @Keerthi0555 , please use as @h_kataria mentioned i.e. path should be in single quote but give relative path.

Remove apps/

PFA,

MukYa1_0-1719304405609.png

 

SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node,'/content/we-retail/us/en')AND node.[sling:resourceType] = 'weretail/components/content/breadcrumb'

 

OR

MukYa1_0-1719304557508.png

SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node,'/content/we-retail/us/en')AND node.[sling:resourceType] LIKE 'weretail/components/content/breadcrumb'

 

So issue is with apps/ as well else it will return zero hit

Both query need minor correction also we can concatenate path as below

String queryString="SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node,'"+path+"')AND node.[sling:resourceType] LIKE 'weretail/components/content/breadcrumb'";

Or
String queryString="SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node,'"+path+"')AND node.[sling:resourceType] = 'weretail/components/content/breadcrumb'";


 

Thanks

Avatar

Community Advisor

@Keerthi0555 

You missed single quote at the end of component path.

 String queryString = "SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node," +path+")"+ "AND [sling:resourceType] = 'apps/components/componentName'"