jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: count function in query?
Date Mon, 19 Jul 2010 16:03:23 GMT
On Mon, Jul 19, 2010 at 17:18, Omid Milani <omilani@gmail.com> wrote:
> Thanks for the response, but this isn't what I wanted.
> I'm trying to get count of something (like tag-references to the node)
> for each row of results, or order my result with it.
> With calling getSize on iterator, I would have to do n+1 queries
> instead of 1, to get the count. and event that wouldn't get the order
> right.

Oh, looks like I didn't read your question properly.

There is no count(*) or group by selector in JCR SQL [1], XPath [2] or

To implement such a tag cloud, you can run one query that fetches all
your content containing the relevant "tag" property:

//element(*, my:Article)[@tag]

and then iterate over the result and count your tags on the
application side by looking at the tag property values and using some
hashmap (tagid -> count).

[1] http://www.day.com/specs/jcr/1.0/ (section 8.5)
[2] http://www.day.com/specs/jcr/1.0/ (section 6.6)
[3] http://www.day.com/specs/jcr/2.0/6_Query.html


Alexander Klimetschek

View raw message