cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene query Association.

joksy
Champ in-the-making
Champ in-the-making
Hi Guys,
This question is about the lucene query syntax, for getting the association. so imagine a situation like this one.
var documentQuery = search.luceneSearch("+(TYPE:\"rsi:documentGuest\") PATH:\"/app:company_home//*\"");
This query return to me an array of documentGuest belong to the company home.
The documentGuest type has one association call rsi:assigned. to another type :rsi:documentAssigned
My ideal goal is to modify this query to search also for the name of  target name of the association.

Until now the only way is to loop for all resultSet like :

function getMyDocument(documentGuest,target,guestName){
   var docArray = new Array();
   
   var internalIndex = 0;
   
   for (var i = 0; i < documentGuest.length; i++){
            if(documentGuest[i].assocs[target] != null){
            var assocstarget = documentGuest[i].assocs[target];
            for(var x = 0;x < assocstarget.length;x++){
               if(assocstarget[x].properties.name == guestName){
                  docArray[internalIndex] = documentGuest[i];
                  internalIndex++;   
               }
            }
         }
      }
   
   return docArray;
   
}

But it is clearly the worste scenario in terms of performance. I really appreciate if someone can help me.
I ve try to red the documentation http://wiki.alfresco.com/wiki/Search but without success.

In the end if with lucene could be impossible do that maybe using xpath a solution can exist.


Thanks a lot guys
1 REPLY 1

pmonks
Star Contributor
Star Contributor
To accomplish this use case you'd need two things:
  1. Associations being indexed into Lucene

  2. Support for projection in Lucene queries
Unfortunately Alfresco/Lucene don't support either of these things, so your solution below is an appropriate approach, and your focus should be on optimising that code.  Have you benchmarked it, and if so what kind of results are you seeing?

Cheers,
Peter