Solr 6 - JAVASCRIPT- get sub-folders starting by ...

Showing results for 
Search instead for 
Did you mean: 
Established Member II

Solr 6 - JAVASCRIPT- get sub-folders starting by ...


I have one site "mySite" with "documentLibrary". Inside I have "PATIENTS" folder :

I don't find the way, in javascript,  to get all sub-folders of "PATIENTS" folder starting by "CA" for example.

I have tried differents method with :

search.query({query: "PATH:/app:company_home/st:sites/cm:mySite/cm:documentLibrary/cmSmiley TongueATIENTS//*"});


search.xpathSearch("/app:company_home/st:sites/cm:mySite/cm:documentLibrary/cmSmiley TongueATIENTS//*");


search.luceneSearch("TYPE:\"cm:folder\" AND @cm\\:title:\"*"+filterTerm+"*\"");

without success...

Thank you

PS : each sub-folder is created by a java mechanism. Is-it possible that a parameter or an action ( may-be permission), during the sub-folder creation, can cancel the sub-folder scan ?

Thank you

1 Reply

Re: Solr 6 - JAVASCRIPT- get sub-folders starting by ...

Never use the luceneSearch operation. It is a legacy remnant and no longer receives any enhancements... Also xpathSearch is not a real XPath search, also going via the legacy Lucene search language with a very reduced XPath subset.

Always stick to query() in Repository-tier JavaScript. I am also wondering why you are querying for "...PATIENTS//*" - this will yield not only the sub-folders, but any descendant node below that folder at any depth. If you only want subfolders, you should simplify the PATH to "...PATIENTS/*" (single slash).

If you want to restrict based on the prefix of the name, you can simply add another condition to your query using AND. E.g. you can append

   AND =cm:name:"AC*"

to query for all sub-folders / descendants with a name starting with AC (case-sensitive)