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

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

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

Hi,

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//*"});

OR

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

OR

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
afaust
Master

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)