COUNT nodes

cancel
Showing results for 
Search instead for 
Did you mean: 
nonets
Active Member

COUNT nodes

We're launching queries like that:

    TYPE:"ts:FolderSet" and ANCESTOR:"workspace://StoreSpaces/234230..."

We need to count how many nodes are matching above condition instead of getting a list of nodes.

We're launching this query using /share TFS-Alfresco queries.

Any ideas?

3 Replies
afaust
Master

Re: COUNT nodes

Yeah. Since this type of query will have to use the SOLR index, simply use the "numberFound" attribute contained in the search response / result set. That gives you the total number of nodes matching that query (that the current user is allowed to see). You can always set the "maxItems" parameter for search to 1, so you don't get a lot of results back (can't set it to zero though).

nonets
Active Member

Re: COUNT nodes

I don't quite figure out how to get this "numberFound" field.

I've tried something like that, but I don't see the number of nodes.

afaust
Master

Re: COUNT nodes

You cannot from the Node Browser tool. You need to access the low-level ResultSet obtained by searching via the SearchService#query (Java) or Search#query (JavaScript) API operations. Alternatively, if you are looking for the whole number without permission checks (you are checking as admin after all), you can simply do a database query or check the SOLR index (schema browser) via its admin UI.