jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: Counting occurences of a given property's different values
Date Thu, 05 Feb 2009 15:22:38 GMT
On Thu, Feb 5, 2009 at 3:46 PM, gregoryjoseph
<gregory.joseph@magnolia-cms.com> wrote:
> Here's what I'd like to do, in semi-sql form:
> SELECT count(*), prop_value FROM nodes WHERE prop_name='foo' GROUP BY
> prop_name
> (or something in that vein, i'd have to refresh my sql 'skills')
> The use case is simply a tag cloud. I have content nodes with one property
> 'tag', which is a multi-value. I want to know how many time each distinct
> value if used over all (or a set of) nodes.

Run your jcr xpath/sql query that selects your desired nodes and then
call QueryResult.getNodes().getSize() to get the number of results.
The query for your case would probably be something like this:

SELECT * FROM my:nodetype WHERE tag='foo'


Alexander Klimetschek

View raw message