cancel
Showing results for 
Search instead for 
Did you mean: 

Find only sub-folders, not type content in javascript search

patrickvanhoof
Confirmed Champ
Confirmed Champ

Hi,

I have following code

nodes = search.query({
	language: 'fts-alfresco',
	query: 'ANCESTOR:"workspace://SpacesStore/a0617f12-8eba-4dce-a5b5-59afec623010"+nodeType:"cm:folder"',
	maxItems: 2000
});

But this gives me also all documents in all sub-folders. I only want objects of type folder.

All help appreciated.

1 ACCEPTED ANSWER

narkuss
Star Contributor
Star Contributor

Have tou tried a query like:

'ANCESTOR:"workspace://SpacesStore/a0617f12-8eba-4dce-a5b5-59afec623010" AND TYPE:"cm:folder"'

View answer in original post

12 REPLIES 12

narkuss
Star Contributor
Star Contributor

Have tou tried a query like:

'ANCESTOR:"workspace://SpacesStore/a0617f12-8eba-4dce-a5b5-59afec623010" AND TYPE:"cm:folder"'

Simple as that Smiley Happy

Thanks!

Hi,

One more question. Why does following code

function main() {
	log = "*** Start script ***\n";
	logFile.content += log;
	
	nodes = search.query({
		language: 'fts-alfresco',
		query: 'ANCESTOR:"workspace://SpacesStore/a0617f12-8eba-4dce-a5b5-59afec623010" AND TYPE:"cm:folder"',
		maxItems: 2000
	});

	log = "   -> Gevonden mappen: " + nodes.length + "\n";
	logFile.content += log;

	log = "*** Einde script ***\n";
	logFile.content += log;
}

var logFile = space.childByNamePath("log.txt");
var nodes = null;
if (logFile == null)
{
   logFile = space.createFile("log.txt");
}
var log = "";
main();

give me an output that repeats the logging a hundred times? I get in the log output file hundred times the 'Start script', 'Gevonden mappen' and 'Einde script'.

Mmmm maybe you are appending the logs to the file at every script execution, instead of creating new content for the file? If that is not the cause, I don't know what could it be... 

I delete the log file before executing the script, so...

The script is executed via a rule on a folder, and it looks like it is executed for each sub-folder in that folder.

Then check that subfolders have the "inherit rules" option deactivated.

Also, depending on how you want to trigger this rule, take a look at the "apply rule to subfolders" option in rule configuration, to see whether it is well configured. 

I deactvated the inherit rules on some of the sub-folders, but the number stays the same. 

The option to apply the rule to subfolders is not activated.

Then I don't know what could it be. It seems the rule is triggering for a lot of nodes. What is your rule configuration, triggers, etc?

image

Nothing special I think. What I think is strange is that it looks like the script executed for each sub-folder.