cancel
Showing results for 
Search instead for 
Did you mean: 

Search for ?? in filenames in whole repo using webscript

svytle
Champ in-the-making
Champ in-the-making
Hi,
We have a strange issue which is bothering  us. Actually there are some files which were created by the external system. So, Alfresco hosts the files of that external system, which posts the files to Alfresco using web scripts.  Since our system is Latin1 and not UTF8, resulted in "??" for any International chars in the file names. Now that we migrated our DB to UTF8 and now we are planning for a web script which replaces '??' to '_' chars.

I was just  trying some sample codes for seraching all the filenames under "Company Home" with '??' in it and to change their names. Please see below:

changeName.get.js
————————————-
var nodes = search.luceneSearch("'+PATH:\"/app:company_home//* \"+@cm\\:name:\"*??*\"'");

for (var i = 0; i < nodes.length; i++) {
      var node = nodes;
      node.properties.name="TestingMarch182009";
     }
———————————————-
But this script is not working since the lucene serach isn't returning any values.
Even I tried searchng using the encoded version like:
"+PATH:"/app:company_home/*"+@cm\\:name:\"_x003f\" from the node browser but no use.

Can you please help me in framing this Lucene serach query?

Thanks for the help!
Sunil
6 REPLIES 6

rogier_oudshoor
Champ in-the-making
Champ in-the-making
The ? is a wildcard in Lucene, just like the *. It will match any 1 character, where the * will match any number of characters.

That being said, i have no clue how to solve your issue. You could potentially crawl your system, simply checking each node in the relevant section of the repository via Java. That will however may cost you (if coded properly) up to 25 ms PER NODE (so 40 nodes per second), so use with caution!

lista
Star Contributor
Star Contributor
Have you tried with a bit more exotic Lucene queries, using Fuzzy or Proximity searches?

http://lucene.apache.org/java/2_1_0/queryparsersyntax.html

svytle
Champ in-the-making
Champ in-the-making
Thanks Lista for your suggestion but I couldn't solve the problem. May be I should follow the method suggested by Rogier.
I was trying a web script  for folder iteration process instead of java based folder iteration. I will see if this helps!

loftux
Star Contributor
Star Contributor
I just created a new wiki page on how to iterate nodes for mass update purposes
http://wiki.alfresco.com/wiki/Iterate_Nodes
It should be possible to adapt to your needs as well.

Not to go off topic, but any feedback on this way of doing mass updating is the correct way of doing things is appreciated. So far I've only tested this on smaller repositories.

svytle
Champ in-the-making
Champ in-the-making
Thanks for the script Loftux. Even I code a similar webscript. I'll let you know once we are done with this update process about the pros and cons.

svytle
Champ in-the-making
Champ in-the-making
Thanks for the script Loftux. Even I coded a similar webscript. I'll let you know once we are done with this update process about the pros and cons.