cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Share :- Lucene Query Doubt in Data WebScript

nove-2011
Champ in-the-making
Champ in-the-making
Hi All and Alfresco Team,

I wrote one data webscript which fetches data from Alfresco Repository.

Inside that webscript , I am searching through LUCENE Query.

I am passing one argument while calling the webscript which is nothing but a folder name in Alfresco Site.

var level = args.folderPath;
var searchQuery = "PATH:\"/app:company_home/st:sites/cm:defaultsite3/cm:documentLibrary/cm:Active"+level+"\" AND TYPE:\"cm:folder\"";

[size=150]I am taking care for putting /cm: before passing argument programatically.[/size]

As I faced issue that from front-end if I am passing Retail then query goes perfectly , but if I pass Customer<space>Report –> Customer Report then Space was not recognized and query goes till Customer which should not be the correct one.

So I found the solution and it is as per below

SPACE Solution : -
var level = args.folderPath;
if(args.folderPath != null)
{
   level = level.replace(" ","_x0020_");
}

Which works perfectly.

But I am also passing some thing like

1) Health & Insurance or
2) Health&Insurance

then the lucene doesn't work

1) Health & Insurance  (Health<space>&<Space>Insurance)

var level = args.folderPath;
if(args.folderPath != null)
{
   level = level.replace(" ","_x0020_");
   level = level.replace(" ","_x0026_");
}

then in Query it goes some thing like

Health_x0020_

in place of level which is not correct

2) Health&Insurance  (Health<EmperSand>Insurance)

var level = args.folderPath;
if(args.folderPath != null)
{
         level = level.replace("&","_x0026_"); // or level = level.replace("\&","_x0026_"); or level = level.replace("&amp;","_x0026_");
                                                               // or level = level.replace("amp;","_x0026_");
}

then in Query it goes something like only

Health

I tested the same query in Node Browser of Alfresco[size=150] it works perfectly for [/size]
PATH:"/app:company_home/st:sites/cm:defaultsite3/cm:documentLibrary/cm:Active/cm:Retail " AND TYPE:"cm:folder"

(Customer Report) Space :- PATH:"/app:company_home/st:sites/cm:defaultsite3/cm:documentLibrary/cm:Active/cm:Customer_x0020_Report " AND TYPE:"cm:folder"

(Health&Insurance) EmperSand :- PATH:"/app:company_home/st:sites/cm:defaultsite3/cm:documentLibrary/cm:Active/cm:Health_x0026_Insurance" AND TYPE:"cm:folder"

(Health & Insurance) Space and EmperSand :-  PATH:"/app:company_home/st:sites/cm:defaultsite3/cm:documentLibrary/cm:Active/cm:Health_x0020__x0026__x0020_Insurance" AND TYPE:"cm:folder"

Please Guide me how to resolve this Lucene Query Issue Programatically ?

Thanks and Regards,
Nove
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
You need to ISO9075 encode your QNames.  There should be a utility to help you.

nove-2011
Champ in-the-making
Champ in-the-making
Dear mrogers,

I forgot to mention in my POST that I have already tried for that but its still not working.

Please Guide sir.

-Nove