cancel
Showing results for 
Search instead for 
Did you mean: 

luceneDateRange does not work in Alfresco Enterprise 4.1.2

ayubalfresco
Champ in-the-making
Champ in-the-making
Hi,

I am trying to run the below query in node browser, however it does not seem to show the result. Could some one point what's the issue ?

below is the query:
<ode>
PATH:"/app:company_home/st:sites/cm:ita/cm:documentLibrary/cm:HR_x0020_Department/*" AND (@cm\:created: \$\{luceneDateRange(yesterday, "P12D")\})

</code>
Is this the same issue ?

https://issues.alfresco.com/jira/browse/ALF-12503

Thanks
Ayub
6 REPLIES 6

afaust
Legendary Innovator
Legendary Innovator
Hello,

you can't use luceneDateRange in a node browser query. The expression ${luceneDateRange(yesterday, "P12D")} is a FreeMarker expression that needs to be evaluated BEFORE it is submitted to the search service. It only works in specific, bean-defined scheduled actions of the type CronScheduledQueryBasedTemplateActionDefinition as far as I know.

Regards
Axel

mitpatoliya
Star Collaborator
Star Collaborator
Your query should be

PATH:"/app:company_home/st:sites/cm:ita/cm:documentLibrary/cm:HR_x0020_Department/*" AND (@cm\:created: [2011\-12\-16T00:00:00 TO 2013\-12\-17T00:00:00])

Something like this

check out this
http://wiki.alfresco.com/wiki/Search#Range_Queries

I also tried to put the query in scheduled action service however it does not bring any records which are older than 12 days. The rage query works however the dates are hardcoded. I want to query documents which are older than X number of days. Any other alternatives ?

mitpatoliya
Star Collaborator
Star Collaborator
You can do it in this query as follow


Date d= new Date();  
Calendar c = Calendar.getInstance();
c.setTime(d);
c.add(Calendar.DATE, -days);
d.setTime( c.getTime().getTime() );
SimpleDateFormat dt = new SimpleDateFormat("yyyyy\-mm\-ddThh:mm:ss");

String formateddate=dt.format(d);
PATH:"/app:company_home/st:sites/cm:ita/cm:documentLibrary/cm:HR_x0020_Department/*" AND (@cm\:created: [MIN TO formateddate])


Something like this

ayubalfresco
Champ in-the-making
Champ in-the-making
Can I use that code in schedule action xml file ?

mitpatoliya
Star Collaborator
Star Collaborator
Place this code in script file and invoke that script file in scheduled action execution.