Skip to main content
Keerthi0555
Level 5
Jun 25, 2024 7:14 AM UTC
Solved

INvalid query exception

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?
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
h_kataria
h_katariaAccepted solution
Community Advisor
Jun 25, 2024 8:02 AM UTC

Try this 

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

3 replies

h_kataria
Community Advisor
h_katariaCommunity AdvisorAccepted solution
Community Advisor
Jun 25, 2024 8:02 AM UTC

Try this 

String queryString = "SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node,'"+path+"')"+"AND node.[sling:resourceType] = 'apps/components/componentName'";
Translate
MukeshYadav_
Community Advisor
Community Advisor
Jun 25, 2024 8:34 AM UTC

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

Remove apps/

PFA,

 

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

 

OR

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

Translate
Anudeep_Garnepudi
Community Advisor
Community Advisor
Jun 26, 2024 1:40 AM UTC

@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'"
Translate
AG