cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript Lucene Search on folder

yteng
Champ in-the-making
Champ in-the-making
Hey guys, i have a problem on lucene search, I want get all documents from a folder called Customer Care under Company Home by luceneSearch in javascript :    

search.luceneSearch ("+PATH:\"/app:company_home/cm:Customer_Care/*\"");  does not work, returns nothing ….

I tried many different ways in this lucene search query, such as, cm:customer care, cm:customer_care, cm:customer%20care, but none of them works.

Does anyone knows how to retrieve contents from that folder (Customer Care) by lucene search?

Thanks in advance.


By the way, I did some experiment, I changed the folder name to "CustomerCare" (removed the space at middle), and called search.luceneSearch ("+PATH:\"/app:company_home/cm:CustomerCare/*\""); it works.
6 REPLIES 6

openpj
Elite Collaborator
Elite Collaborator
You have to encode the string in the PATH token using the ISO9075 encoding.
In Javascript you can use a specific method that you can invoke from the search object, in the following way:

var queryEncoded = search.ISO9075Encode("/app:company_home/cm:Customer_Care/*");
var results = search.luceneSearch(queryEncoded);
Hope this helps.

yteng
Champ in-the-making
Champ in-the-making
Thank You so much for your reply OpenPj Smiley Happy

You may misunderstood my problem: LucnenSearch does not work if the folder name contains blank space. 
and I figured out that in the luceneSearch path, replace the space with "_0020_", then it works!!!

grob
Champ in-the-making
Champ in-the-making
Does anyone have a solution for this issue?
I have exactly the same problem, i need to do a lucene search in a specific space… When the name (of the space) contains whitespace i get no results. I tried to escape the whitespace with \ but it doesn't help.
For example:
Everything works perfect for spaces like: Applications, Sites, Archive -  PATH:"//cm:Applications/*"
When search in Customer Documents or. Guest Home i get no results….  - PATH:"//cm:Customer Documents/*"
Thanx for help!

grob
Champ in-the-making
Champ in-the-making
Lol  Smiley Very Happy

I had to use ISO9075Encode, but like this: PATH:"//cm: search.ISO9075Encode(Customer Documents)/*"

fstnboy
Champ on-the-rise
Champ on-the-rise
As openPJ and grob has said you should use the ISO9075 encoding when using lucene searches in javascript.

On the other hand, the underscore shouldn't be a problem to that, so it may be that you'll have to reindex your lucene indexes. For that purpose edit the alfresco-global.properties file and uncomment the next line


index.recovery.mode=FULL

then try it again.

Hope it helps…

grob
Champ in-the-making
Champ in-the-making
fstnboy, thnx for the hint. I'll try it out!
Regards