cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene query not working

nancyaggarwal
Champ in-the-making
Champ in-the-making
hi,


I have written one webscript in alfresco for assigning user role on a folder. But the query which i have written for finding the folder is not working. Below is my webscript controller:



/*Set permission to a folder using Alfresco javascript API*/

//search for the folder node using lucene search

var folderNode =  search.luceneSearch('+PATH:"/app:company_home/cm:testing/*"  AND TYPE:\"cm:folder" AND @cm\\:name:"test"');

//make sure we only get one node
if(folderNode.length == 1){

//set permission "Contributor" to user with username "anythingalfresco" and group "ANYTHINGALFRESCOGROUP"

folderNode[0].setPermission("Contributor", user);
folderNode[0].setInheritsPermissions(false);
model.myStatus = "Permission was set successfully!";
}else  if (folderNode.length == 0){
//no node was found
model.myStatus = "Folder not found";
}else{
//either greater than two  was found
model.myStatus = "Duplicate folder found";
}



It is giving me folder not found error. I have test folder inside testing folder but still it is giving mr folder not found error.


Please help me what is wrong in my lucene query or is there something else which is not working.


Regards,
Nancy
2 REPLIES 2

hardik1512
Star Contributor
Star Contributor
Try with below line.  It should work.

var folderNode =  search.luceneSearch('PATH:"/app:company_home/cm:testing/*" AND TYPE:"cm:folder" AND @cm\:name:"test"');

Thanks Hardik for your reply.

I tried with this 'PATH:\"/app:company_home/cm:testing/*" AND TYPE:"cm:folder"  AND "=cm\:name:"' +args.folderName)


args.folderName=test and it is giving folder not found

but with the same query in node browser is returning me the node

What is wrong in my controller?







Regards,
Nancy