cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene date query

swejja
Champ in-the-making
Champ in-the-making
Hi!

I am working on a custom model for a contract notification system for a client. We need to make a lucene query to get all contracts that has a startdate between two dates. I have read and tried everything I can find in the forum and in the wiki.

If I do an ordinary date search with an startdate and enddate it works (in this specific query I get two nodes as a result)
@sssb\:ContractStartDate:[2009\-09\-01T00:00:00 TO 2009\-10\-20T00:00:00]

But I would really like to be able to use the daterange function below

@sssb\:ContractStartDate:${luceneDateRange(today, "P1Y")} 
(Found in: http://wiki.alfresco.com/wiki/Scheduled_Actions and http://forums.alfresco.com/en/viewtopic.php?f=3&t=20573)

I have tried all kinds of different character escapes and syntaxes to get it right but I dont get it to work.
@sssb\:ContractStartDate:$[luceneDateRange(today, "-P10Y")] 
or
@sssb\:ContractStartDate:$[luceneDateRange(today, \"P100Y\")] 

What am I doing wrong? We are using Alfresco (Version: Community - v3.2.0 (2268))

Best regards, Joakim
2 REPLIES 2

mikeh
Star Contributor
Star Contributor
The luceneDateRange function (plus the "today", "yesterday" and "tomorrow" keyowrds) are only available to scheduled actions, as they've been added to Freemarker in org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory

You could either extend the web script Freemarker processor to provide the same functionality, or simply write some Freemarker macros to do the same thing.

Thanks,
Mike

swejja
Champ in-the-making
Champ in-the-making
Thank you very much Mike for you quick reply. Wonderful! This answers a bunch of my questions. Have a great day!

Best regards,
Joakim