3

How to get specific content type document count in alfresco share UI using Lucene query?

I have tried to query in alfresco share UI Alfresco Lucene query. but it's only giving first 100 results.

Is there any best way to get only document count by specific content type or document count under specific alfresco site??

Please suggest if there is any other best and useful way.

Thanks in Advance.

Deepak Talape
  • 997
  • 1
  • 9
  • 35
  • You're hitting a standard Lucene/SOLR limit, Google it. There are ways to achieve this, but they're not something that's standard at all. What are you trying to achieve here? – Lista Oct 26 '17 at 20:51
  • I just want to get count of documents under specific site or if possible, I want a count inside site with specific type – Deepak Talape Oct 27 '17 at 05:50
  • I also tried using database query, but if we delete any document from alfresco share, its entry still present in DB. so there is count mismatch.. – Deepak Talape Oct 27 '17 at 05:51
  • 2
    It may be still present, but it changes store, so there is a way to filter them out. Check the following link for inspiration: https://blog.dbi-services.com/alfresco-some-useful-database-queries/ – Lista Oct 27 '17 at 07:04

3 Answers3

3

The class PatchDAO has a method that returns the number of node with a given type:

/**
 * Gets the total number of nodes which match the given Type QName.
 * 
 * @param typeQName the qname to search for
 * @return count of nodes that match the typeQName
 */
public long getCountNodesWithTypId(QName typeQName);

where typeQName is, of course, the QName of the type.

This method should return the total count and should be the most efficient.

UPDATE: If you need the count on a specific site this method is not actually usable.

Marco Altieri
  • 3,726
  • 2
  • 33
  • 47
2

ResultSet result = searchService.query(, SearchService.LANGUAGE_LUCENE, "+PATH:\"/app:company_home/cm:" + + "/*\"" + " +TYPE:\"" + + "\"" );

You can change the parameters as per your need.

Thanks,

Kintu

Kintu Barot
  • 320
  • 2
  • 11
2

Hitting the database directly is a very bad idea, so don't even start getting into that bad habit.

Using the Alfresco foundational Java API would require that the Java class be deployed to the server, which is a pain.

The easiest way to do this is to use OpenCMIS. You can run OpenCMIS code remotely, and you can use its paging result set to page through the query results, see Apache CMIS: Paging query result

Jeff Potts
  • 10,468
  • 17
  • 40
  • I agree that in general it is better to use an higher level API, but to count the number of documents directly accessing the repository is an unusual requirement that cannot be implemented efficiently with CMIS. What would happen if there are millions of documents? – Marco Altieri Nov 11 '17 at 14:09
  • Of course, CMIS is ok if the number of documents is reasonable. A few thousand, for example. – Marco Altieri Nov 11 '17 at 16:19
  • Hi Jeff, I don't agree that accessing the DB directly for counting specific docs is a bad idea if alfresco does not provide a reliable api to report / count nodes (at least in CE).Of course you could put the required query into a java implementation and expose that to javascript or use that in a dashlet. – Heiko Robert Aug 18 '20 at 09:50
  • Hi Robert! The DB schema is not considered public. So you are basically telling people to use the equivalent of an internal-only API. That carries with it the usual potential problems down the road when it is time to upgrade, not to mention the potential performance problems that an ill-formed query could cause. Of course it is all there for people to do with what they will, but it really shouldn't be encouraged. – Jeff Potts Aug 20 '20 at 01:07