cancel
Showing results for 
Search instead for 
Did you mean: 

Searching across non-child associations

si_hutch
Champ in-the-making
Champ in-the-making
Hi,

I am brand new to Alfresco so please excuse the naivety of my first post.

I have read on the wiki that "Alfresco's search languages do not yet support joins across non-child associations."

Nevertheless I am working on a content model that has a requirement for such a search.

Could someone please offer me some advice on the most appropriate workaround for conducting such a search.

i.e How can I find all instances of a source that has an association with a non-child destination?

Thanks

Si
2 REPLIES 2

jbarmash
Champ in-the-making
Champ in-the-making
Note: I am not an expert on search. 

However, assuming you are doing this search programatically somehow, could you walk the associations and add constraints to search to point to all elements. 

I.e. if you have A that has a peer with B and C, (programatically) create a search that constrains the search to A, B, C files only? 

Could that work in your use case?

si_hutch
Champ in-the-making
Champ in-the-making
Thanks for getting back to me.

Would constraints allow me to conduct the following type of search?

i.e

I want to return all A's and only A's that have at least one association with B

My current approach works (see snippet below) but it is not optimal as I have to first search for all the "NodeRefAs" and then for each get the target associations.
Could you  please provide a small example walk-through of how I could use constraints to constrain the initial search query for "NodeRefAs" to be limited to those
with an association to B?


for(NodeRef NodeRefA: NodeRefAs) {
   List<AssociationRef> ABAssociationRefs= nodeService.getTargetAssocs(NodeRefA,
      MyContentModel.ASSOC_A_TO_B);      
   if(ABAssociationRefs.size() >0)            
      //etc……   
}