Query Association

Showing results for 
Search instead for 
Did you mean: 

Query Association

Query Association

0 Kudos

I am looking for some better and faster way to find child associations.

For example, I have one type(my:accounts) which stores the reference data and this type is associated with multiple nodes of type(my:doc). I want to query my documents(my:doc) where reference data(let’s say account_id=001) is tagged as association. I learned from different Alfresco forums that we can’t directly query associations. Only option I can see is search for reference data(my:accounts where account_id=001) and then iterate over the results to get parent nodes(my:doc).

Is there any easy and faster way to get all the documents(my:doc) with pagination like we get search results?

Alfresco Employee

Hi @milinp 

Have you seen these database query examples? You may be able to adapt one of these, depending on your requirements?

Senior Member


It's sometimes hard to accept that Alfresco's metadata is stored like in a hierarchical database if you're used to do queries in a relational database using joins. In principle Alfresco's hierarchical repository concept does not support joins in that way. Everything you want to query needs to be stored on the same node (or better index document).

One work around we use sometimes for custom assocs is mirroring the required metadata by custom behavior automaticaly to the other node on any change. This allows you to search for documents having account_id=001 although nobody stored that property (manually) on that node.

In use cases as you describe with account_id we don't use assocs at all but store the account_ids in a aspect. Does this make sense for you?

Member II


Yes, we have implimented the same. On create/udpate node we add cusotm propertie to the node. I guess this is most simplest solution to store and search metadata. But problem is when I need to do bulk update on the nodes. For example, if I need to update account_name for all the nodes(may be millons) where account_id=001 then I need to touch millons of nodes and this take lots of time. 

If I have assocations then I just need to udpate only one node where my refrence data is stored.