I am attempting to grab multiple nodes of the same type from different areas in the jcr and order them by a 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 altering DESC to ASC does not alter the results in any way.
My solution currently is to do multiple queries and perform a union which allows ORDER BY to function like 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 around 30 nodes that I am searching through making the latter query unusable. Is there a way to use ORDER BY without using a UNION?