How to use order with multiple isdescendantnode

I am trying to capture several nodes of the same type from different areas in jcr and sort them by date.

SELECT * FROM [social:asiResource] 
WHERE [sling:resourceType] = 'social/qna/components/hbs/topic' AND 
[isFeatured_b] = true AND 
NOT CONTAINS([cq:tags],'administrative:blacklist') AND 
(ISDESCENDANTNODE([/path/to/content]) OR 
ISDESCENDANTNODE([/path/to/content]))
ORDER BY [cq:lastModified] DESC

This will return me the correct set of results, but not in the correct order. In fact, the change DESCto ASCnot change the results.

My solution at the moment is to execute several queries and do a join that allows it to ORDER BYfunction as it should.

SELECT * FROM [social:asiResource] 
WHERE [sling:resourceType] = 'social/qna/components/hbs/topic' AND 
[isFeatured_b] = true AND 
NOT CONTAINS([cq:tags],'administrative:blacklist') AND 
ISDESCENDANTNODE([/path/to/content]) 
UNION 
SELECT * FROM [social:asiResource] WHERE 
[sling:resourceType] = 'social/qna/components/hbs/topic' AND 
[isFeatured_b] = true AND 
NOT CONTAINS([cq:tags],'administrative:blacklist') AND 
ISDESCENDANTNODE([/path/to/content])
ORDER BY [cq:lastModified] DESC

Unfortunately, I have about 30 nodes that I am looking to make the last request unusable. Is there any way to use ORDER BYwithout using UNION?

+6
1

. , , , ORDER BY .

, ORDER BY ISDESCENDANTNODE.

0

Source: https://habr.com/ru/post/1015765/


All Articles