INvalid query exception | Community
Skip to main content
Keerthi0555
June 25, 2024
Solved

INvalid query exception

  • June 25, 2024
  • 2 replies
  • 803 views

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.
Best answer by h_kataria

Try this 

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

2 replies

h_kataria
Community Advisor
h_katariaCommunity AdvisorAccepted solution
Community Advisor
June 25, 2024

Try this 

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

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

Anudeep_Garnepudi
Community Advisor
Community Advisor
June 26, 2024

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