Create Range Query in Alfresco

In my post content Modeling in Alfresco we had seen that alfresco supports metadata of different data types like string, integer, and date. Also in this earlier post we had seen how content search work in alfresco.

In content search post we have also learnt about content search in Alfresco repository. Most of the time we need to deal with Lucene queries in order to search though the repository. Now for properties with different data type needs to be handled differently while generating query. Here I am going to show explain you two type of queries where generally developers face difficulties.

Query for property of type Date

All properties with Date value are stored in the Alfresco in ISO 8601 date time format


So query parser expects the date in same ISO 8601 format truncated forms of this date are also supported. Alfresco also support few token like TODAY, NOW, MIN, MAX to make it more easy.

Finding nodes by date and time property values

For instance we have property called empjoiningDate with data type as date where “custom” is the model prefix.


Finding Nodes with token

@cm\:created:NOW (find all the nodes created today)

Range Query for property of type Date

For searching between two given dates we need to create Date Range query.

@custom\:empjoingDate:[2010\-10\-16T00:00:00 TO 2014\-10\-17T00:00:00]
 @custom\:empjoingDate:[2013\-10\-16T00:00:00 TO MAX]
 @custom\:empjoingDate:[NOW TO MAX]
 @custom\:empjoingDate:[MIN TO NOW]


Range Query for property of type integer

For property with data type integer we sometimes have requirement to search for all the nodes which has value of that property set within given range.

For instance we have property called employee id with data type int for custom content type employee bio data and we want to search employees’ bio data with id between 30 and 60.

@custom\:employeeId:[30 TO 60](Inclusive of both range)<b></b>
@custom\:employeeId:{30 TO 60}(Exclusive of both range)

Hope this will give you very good insight of how to generate Range queries for date and integer.

Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight


I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *