[ 
https://issues.apache.org/jira/browse/JCR-2302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12754038#action_12754038
 ] 

Marcel Reutegger commented on JCR-2302:
---------------------------------------

> It would be useful if it always follows the same order in that case (also for 
> multiple executions of the same query), so that components that 
> automatically show you the latest content by running a query every 20 seconds 
> or so have a stable result. 

IIRC the result is stable in jackrabbit, it just may be different depending on 
how ordering is calculated. 

A little bit of background info: there are two implementations responsible for 
result ordering: 

- RelPathScoreDocComparator, this one is generally used when you have an order 
by with a relative path 
- SimpleScoreDocComparator, this one is generally used when you have an order 
by on a property of a result node 

there's one exception though, when you define an index aggregate with a 
include-property that matches the relative path of your order by, then the 
SimpleScoreDocComparator is used. 

I think it is be up to the application if it want to put additional ordering on 
the result set. Either by applying that ordering manually after the query 
execution or by specifying a secondary order property.

> Child axis support in order by clause does not work
> ---------------------------------------------------
>
>                 Key: JCR-2302
>                 URL: https://issues.apache.org/jira/browse/JCR-2302
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core, jackrabbit-spi-commons, xpath
>    Affects Versions: 2.0-alpha9
>            Reporter: Alexander Klimetschek
>            Priority: Minor
>
> Child axis support for order by in xpath queries was introduced with JCR-800.
> In my use case I have a cq:Page nodetype which has a jcr:content child of 
> type cq:PageContent (like nt:file and nt:resource). The jcr:content child has 
> a cq:lastModified time stamp that I want to search on. I use descending to 
> see the most recently modified nodes at the top.
> The problem is that it does not work when using a child axis in the order by:
> (1) //element(*, cq:Page) order by @jcr:content/cq:lastModified descending
> This gives a different (and wrong) result compared to the simpler query on 
> level deeper, which returns the correct results:
> (2) //element(*, cq:PageContent) order by @cq:lastModified descending
> Switching between ascending and descending in (1) does not change the result 
> set at all, ie. the order stays the same.
> A reason could be non-existing properties (of which there are some in my 
> data), so to only look at existing properties, I run this query, which still 
> gives incorrect results:
> (3) //element(*, cq:Page)[jcr:content/@cq:lastModified] order by 
> @jcr:content/cq:lastModified descending

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to